dagger-reflect
dagger-reflect copied to clipboard
dagger-reflect more strict than dagger-compiler (scopes)
In our application we have structure similar to this one:
@Singleton
@Component
interface MainComponent {
fun feature(): FeatureComponent
}
@Subcomponent
interface FeatureComponent {
fun plus(module: SubFeatureModuleA): SubFeatureComponentA
fun plus(module: SubFeatureModuleB): SubFeatureComponentB
}
@Scope
@Retention(RUNTIME)
annotation class SubFeatureScopeA
@Module
class SubFeatureScopeA {
@Provides
@SubFeatureScopeA
fun provideSomething(something: Something): ISomething = something
}
@Subcomponent(modules = [SubFeatureModuleA::class])
@SubFeatureScopeA
interface SubFeatureComponentA {
fun inject(fragment: SubFeatureAFragment)
}
(sometimes also FeatureComponent has some modules defined, but it's irrelevant in this case)
For such case, we get following exception in runtime:
Caused by: java.lang.IllegalStateException: Scope with annotations [@com.myapp.SubFeatureScopeA()] may not depend on unscoped
at dagger.reflect.Scope$Builder.<init>(Scope.java:167)
at dagger.reflect.ComponentScopeBuilder.get(ComponentScopeBuilder.java:115)
at dagger.reflect.ComponentInvocationHandler$SubcomponentMethodInvocationHandler.invoke(ComponentInvocationHandler.java:180)
at dagger.reflect.ComponentInvocationHandler.invoke(ComponentInvocationHandler.java:70)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy44.plus(Unknown Source)
while the dagger-compiler (2.26) allows such construct and works fine.
Same issue.