Auto-Dagger2 icon indicating copy to clipboard operation
Auto-Dagger2 copied to clipboard

@Named annotations in constructor

Open peppered opened this issue 8 years ago • 0 comments

Hi! I'm using Architect-Robot and it seems that Auto-Dagger2 doesn't handle @Named arguments. E.g. I have the following class (with multiple Scheduler arguments):

@AutoStackable(
        component = @AutoComponent(includes = FromActivityAutoComponent.class),
        pathWithView = SignUpView.class
)
@AutoExpose
@DaggerScope(SignUpPresenter.class)
public class SignUpPresenter extends ViewPresenter<SignUpView> {

    private AccountManager accountManager;
    private Scheduler ioScheduler;
    private Scheduler mainScheduler;

    public SignUpPresenter(AccountManager accountManager, @Named("scheduler.io") Scheduler ioScheduler, @Named("scheduler.main") Scheduler mainScheduler) {
        this.accountManager = accountManager;
        this.ioScheduler = ioScheduler;
        this.mainScheduler = mainScheduler;
    }
}

During the build I get the following error:

Error:(19, 8) error: rx.Scheduler cannot be provided without an @Provides-annotated method.
architect.commons.view.PresentedLinearLayout.presenter
[injected field of type: ui.signup.SignUpPresenter presenter]
ui.signup.stackable.SignUpStackable.Module.providesPresenter(services.AccountManager accountManager, rx.Scheduler ioScheduler, rx.Scheduler mainScheduler)
[parameter: rx.Scheduler ioScheduler]

And I found that generated module looks as follows (without @Named annotations)

@dagger.Module
public class Module {
  @Provides
  @DaggerScope(SignUpPresenter.class)
  public SignUpPresenter providesPresenter(AccountManager accountManager, Scheduler ioScheduler, Scheduler mainScheduler) {
    return new SignUpPresenter(accountManager, ioScheduler, mainScheduler);
  }
}

peppered avatar Apr 25 '16 09:04 peppered