This is what I currently have and it works:
@FragmentScope
@Component(dependencies = {FacebookComponent.class},
You can't use scoped components in a dependencies array (which is quite strange I have to say), only unscoped, or one scoped + other unscoped. But you can deceive dagger with "proxy" interfaces:
@Component
@Singleton
interface ComponentA {
fun provideSomeA()
}
interface ProxyComponentA : ComponentA
@Component
@Singleton
interface ComponentB {
fun provideSomeB()
}
interface ProxyComponentB : ComponentB
@Component(dependencies = [ProxyComponentA::class, ProxyComponentB::class])
@OtherScope
interface ComponentC
But in your ComponentC builder you should use proxy components implementations, which could easily be achieved with Kotlin:
class ProxyComponentAImpl(private val delegate: ComponentA) : ProxyComponentA, ComponentA by delegate
class ProxyComponentBImpl(private val delegate: ComponentB) : ProxyComponentB, ComponentB by delegate
componentA = DaggerComponentA.builder()...
componentB = DaggerComponentB.builder()...
componentC = DaggerComponentC.builder()
.componentA(ProxyComponentAImpl(componentA))
.componentB(ProxyComponentBImpl(componentB))
Works on dagger version 2.13, don't know about others
Also you could use vice versa inheritance ComponentA : ProxyComponentA to eliminate the need to create ProxyComponentAImpl, but it's not a good design choice if your ComponentA lays for example in a different gradle module
The solution was inspired by that issue discussion: https://github.com/google/dagger/issues/1225