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

@BindValueIntoMap fields must have exactly one @MapKey. Found [] #2710

Closed
tynn opened this issue Jun 19, 2021 · 2 comments · Fixed by #2732
Closed

@BindValueIntoMap fields must have exactly one @MapKey. Found [] #2710

tynn opened this issue Jun 19, 2021 · 2 comments · Fixed by #2732

Comments

@tynn
Copy link

tynn commented Jun 19, 2021

This error is triggered by BindValueMetadata:

@BindValueIntoMap fields must have exactly one @mapkey. Found []

So in general this feature might be working with custom keys, but not with with any of the provided @MapKey defining @Target(METHOD) to only allow to annotate methods

  • @ClassKey
  • @IntKey
  • @LongKey
  • @StringKey
@Chang-Eric
Copy link
Member

Just to make sure I'm understanding, when you get that error you must also get some error from the compiler saying that the @ClassKey or whichever one you are using cannot be applied to a field, right?

I assume this issue is less about the error message and more about a request to add the target to those dagger annotations. Is that correct?

@tynn
Copy link
Author

tynn commented Jun 23, 2021

Yes, the error for adding a provided map key to a property is:

This annotation is not applicable to target 'member property with backing field' and use site target '@field'

In my case I was using @StringKey("...").

I raised the issue here as the error itself could not be resolved. Adding the target might be the simples solution, but not the only one. In general I would like to request a working example (for Kotlin) or test case to use @BindValueIntoMap for testing purposes.

copybara-service bot pushed a commit that referenced this issue Jun 30, 2021
…alueIntoMap.

Fixes #2710

RELNOTES=Add the target field to Dagger map key types to support Hilt's @BindValueIntoMap. #2710
PiperOrigin-RevId: 382375535
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