I'm using the Dagger2 AndroidInjector and Kotlin. I have a subcomponent with its module defined in this way:
@Subcomponent(modules = arrayOf(
UIModule::class,
HomeActivitySubcomponent.ComponentModule::class
))
interface HomeActivitySubcomponent : AndroidInjector<HomeActivity> {
@Subcomponent.Builder
abstract class Builder : AndroidInjector.Builder<HomeActivity>()
@Module
abstract class ComponentModule {
@Binds
@IntoMap
@ActivityKey(HomeActivity::class)
internal abstract fun bindMainActivityInjectorFactory(builder: Builder): AndroidInjector.Factory<out Activity>
}
}
If this was java I could add a static @Provides method to the ComponentModule @Module. It has to be static because Dagger complains if I add a non-static method to an @Module class that uses @Binds:
Error:A @Module may not contain both non-static @Provides methods and abstract @Binds or @Multibinds declarations
The problem is: how can I do this with Kotlin?