google/dagger

Multibinding with Nested Complex Keys uses the wrong AnnotationCreator

martofeld opened this issue · 1 comments

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

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!