Dagger 2 Named Set Injection

2.4k views Asked by At

I have a injection point:

public class Receiver {
  private final Set<Sender> senders;

  @Inject
  public Receiver(@Named("Test") Set<Sender> senders){
     this.senders = senders;
  }
}

Moreover I have this module providing the dependency:

@Module
public class MyModule {
  @Provides(type = Provides.Type.SET)
  @Singleton
  @Named("Test")
  public Sender provideSender(){
     return new SpecificSender();
  }
}

But dagger 2 APT cannot create the appropriate classes. I get this exception from the APT:

Caused by: java.lang.UnsupportedOperationException
at dagger.internal.codegen.KeyVariableNamer.apply(KeyVariableNamer.java:44)

Does anyone have the same issue? Is there a good workaround?

If I drop the Named annotation it does work. I'm using Dagger 2.0

Thank you

1

There are 1 answers

3
netdpb On

This has been fixed internally, but is not yet synced to github.