Improve @Provides circular dependency detection
afollestad opened this issue · 0 comments
afollestad commented
Below, SomeClass<String, Boolean>
includes OneImpl
in its @Provides
method. OneImpl
injects SomeClass<String, Boolean>
into its constructor.
@Module
interface MyModule1 {
@Binds fun one(one: OneImpl): One
@Binds fun two(two: TwoImpl): Two
}
@Module
abstract class MyModule2 {
@Provides fun one(one: OneImpl): SomeClass<String, Boolean> = SomeClass("test", true)
@Provides fun two(two: TwoImpl): SomeClass<Int, Long> = SomeClass(6, 10L)
}
interface One {
fun doSomething()
}
class OneImpl(
private val two: Two,
private val idk: SomeClass<String, Boolean>
) : One {
override fun doSomething() = two.doSomething()
}