-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Violating @Singleton definition and bypassing "depends on more than one scoped component" error #1225
Comments
This is either Working As Intended and/or something that we could not reasonably detect. At runtime, there's no way to detect that a component dependency instance is one that was generated by Dagger. Even if we could, there wouldn't be much meaning to that - a Dagger-generated component is just like any other implementation of that interface/abstract class. Restricting the exact implementation allowed could even cause issues with repackaging/shading. And if there's no reason the runtime type must be a component, why must the compile-time type be a component? Often when we see "non-components" as dependencies, they are base types of what will eventually be a component. Something like this: interface AppComponent {
App app();
}
@Component(dependencies = AppComponent.class)
interface RequestComponent { ... }
@Component
interface EnglishAppComponent extends AppComponent {}
@Component
interface SpanishAppComponent extends AppComponent {} |
I got it. Thank you for the quick response. |
@ronshapiro, could you please explain one more thing? |
Hi. I found example where we can create two singletons in hierarchy:
Why does Dagger2 allow passing interfaces not annotated with Component annotation to dependencies attribute?
The text was updated successfully, but these errors were encountered: