Wrong codegen behavior when trying to inject instance with Qualifier but component has instance without Qualifier in its dependencies
See original GitHub issueHello!
I’ve just faced an issue when tried to inject one instance with qualifier when my component has another component which provides instance without qualifier in its dependencies.
For instance, there’s two components:
ComponentA
ComponentB
(depends on ComponentA
).
ComponentA
provides Sample
without qualifier.
ComponentB
provides Sample
with qualifier @BImpl
I’m trying to inject Sample
with qualifier to Container
:
class Container {
@Inject
lateinit var sampleA: Sample
@Inject
@BImpl
lateinit var sampleB: Sample
}
But both samples are ImplA
.
Is it intended behavior? Because for me this is unexpected and seem like a bug.
Here’s a sample project: https://github.com/IlyaGulya/Dagger2QualifierBugSample
Please run test dagger2qualifiersample.TestSample.example()
to reproduce the issue. Both calls prints ImplA
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top Results From Across the Web
Spring @Qualifier isn't working without @Primary [duplicate]
So, I am trying to learn my way with Spring Boot. I tried @Qualifier and @Autowired but it gives me the following error:...
Read more >Troubleshooting contexts and dependency injection - IBM
Disambiguate the injection point by adding a qualifier to the injection point and if necessary, one source of the dependency. If necessary, ...
Read more >Tasting Dagger 2 on Android. | Fernando Cejas
Dependencies can be injected into a component: it is possible to inject mock implementations of these dependencies which makes testing easier.
Read more >Eager Initialization of Singletons - Micronaut Documentation
A bean is an object that has its lifecycle controlled by the Micronaut IoC ... for a given interface that you want to...
Read more >ActiveJ Inject Basics | Lightning-fast and ultimately powerful ...
Applications are made up of components, and each component has an ... Object qualifier (useful when you want to distinguish between keys of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reopening this as it’s probably a good area for us to document
Closing since this is fixed in https://github.com/google/dagger/releases/tag/dagger-2.25.2 and there’s no more need to document it.