Skip to content

2.12: Possible compilation error with @Binds #896

Description

@Martin-Luft

Updating from 2.11 to 2.12 breaks my whole build.

this.addressPresenterProvider =
        DoubleCheck.provider(
            AddressPresenter_Factory.create((Provider) addressViewProvider, eventBusProvider));

The method provider(Provider) in the type DoubleCheck is not applicable for the arguments (Factory)

This happens when using @Binds, but not with an identical @Provides method

This does not work anymore:

@Module
public abstract class ClientMobileModule {

  @Binds
  @Singleton
  public abstract AddressViewInterface addressView(AddressView addressView);
@Singleton
public class AddressView implements AddressViewInterface {

  @Inject
  AddressView() {
  }

This works (using @provides instead of @BINDS):

@Module
public final class ClientMobileModule {

  @Provides
  @Singleton
  public static AddressViewInterface addressView(AddressView addressView) {
    return addressView;
  }
@Singleton
public class AddressView implements AddressViewInterface {

  @Inject
  AddressView() {
  }

This also works (removing @singleton from the view implementation):

@Module
public abstract class ClientMobileModule {

  @Binds
  @Singleton
  public abstract AddressViewInterface addressView(AddressView addressView);
public class AddressView implements AddressViewInterface {

  @Inject
  AddressView() {
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions