Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dagger-reflect more strict than dagger-compiler (scopes) #186

Open
plnice opened this issue Jan 31, 2020 · 1 comment
Open

dagger-reflect more strict than dagger-compiler (scopes) #186

plnice opened this issue Jan 31, 2020 · 1 comment

Comments

@plnice
Copy link

plnice commented Jan 31, 2020

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.

@naixx
Copy link

naixx commented Mar 28, 2020

Same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants