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

Multibinding with Nested Complex Keys uses the wrong AnnotationCreator #4262

Closed
martofeld opened this issue Mar 13, 2024 · 1 comment
Closed

Comments

@martofeld
Copy link

Problem

I'm trying to use multi-injection to provide 2 different maps of ComplexKey -> Provider<Type>. This works great as long as the ComplexKey does not have a parameter that is also a Complex Key. This error ONLY occurs when the nested value is requested as an array, not if requested as a single value.

Snippet

// This works perfectly
@MapKey(unwrapValues = false)
annotation class TopKey(val value: String, val otherValue: Boolean)

// This fails
@MapKey(unwrapValues = false)
annotation class TopKey(val value: String, val otherValues: Array<NestedKey> = [])

@MapKey(unwrapValues = false)
annotation class NestedKey(val value: String, val otherValue: Boolean)

// This also works
@MapKey(unwrapValues = false)
annotation class TopKey(val value: String, val otherValues: NestedKey = NestedKey("", false))

@MapKey(unwrapValues = false)
annotation class NestedKey(val value: String, val otherValue: Boolean)

Repo

I've created this small repo to repro https://github.com/martofeld/dagger-multibinding-issu

@wanyingd1996
Copy link

I built the repro and got the error for :

TopKeyCreator.createTopKey("example3", new NestedKey[] {TopKeyCreator.createNestedKey(Zoo.class, Example3.class)})

This seems to be a bug from Dagger, as the createNestedKey is generated for NestedKeyCreator, I think here, we should get the creator name with the annotation passed in.

I will send out a fix shortly, thanks for reporting it!

copybara-service bot pushed a commit that referenced this issue Mar 21, 2024
When generating creator for annotation, the case when the return type is an array was ignored previously.

fixes #4262

RELNOTES=n/a
PiperOrigin-RevId: 616200494
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

Successfully merging a pull request may close this issue.

2 participants