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

fix: custom qualifier annotations not generating qualifier at injection point #211

Merged

Conversation

skyecodes
Copy link

Following #176, after some testing on v2.0.0-Beta3, I found that the custom qualifier annotations do not generate the qualifier when used to inject a parameter, which would in most cases cause a NoDefinitionFoundException at runtime.

This PR addresses the issue by correctly generating the corresponding qualifier.

Example:

@Named
public annotation class WhiteBunny

@Qualifier
public annotation class BlackBunny

@Single
public class Farm(@WhiteBunny public val whiteBunny: Bunny, @BlackBunny public val blackBunny: Bunny)

Generated code before fix:

single() { _ -> org.koin.example.animal.Farm(whiteBunny=get(),blackBunny=get()) }

Generated code after fix:

single() { _ -> org.koin.example.animal.Farm(whiteBunny=get(qualifier=org.koin.core.qualifier.StringQualifier("org.koin.example.animal.WhiteBunny")),blackBunny=get(qualifier=org.koin.core.qualifier.StringQualifier("org.koin.example.animal.BlackBunny"))) }

This test case has been added to the existing unit test.

@arnaudgiuliani arnaudgiuliani added this to the 2.0 milestone Jan 21, 2025
@arnaudgiuliani arnaudgiuliani merged commit 8c01fd6 into InsertKoinIO:2.0.0 Jan 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants