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

Suggestion: Improve error message when Provider/Lazy are accidentally used in multibindings #3677

Closed
ZacSweers opened this issue Dec 23, 2022 · 1 comment

Comments

@ZacSweers
Copy link

ZacSweers commented Dec 23, 2022

This snippet may be accidentally written to declare a multibinding

@Module
interface Example {
  @Multibinding
  Map<String, Provider<String>> someBindings();
}

The error is that it's using a Provider in the declaration when it should just be Map<String, String>. However, the error message is a little confusing as it seems to imply that it's not a Map at all.

error: @Multibinds methods must return Map<K, V> or Set<T>

I think it would be easier for folks to debug if this message could be more explicit, such as mentioning that dagger intrinsic types like Provider and Lazy are not supported and mentioning if it sees one in the signature.

copybara-service bot pushed a commit that referenced this issue Jan 9, 2023
Fixes #3677

This CL also cleans up an old TODO.

RELNOTES=Fixes #3677: Better error messages for invalid @Multibinds types.
PiperOrigin-RevId: 500752608
copybara-service bot pushed a commit that referenced this issue Jan 9, 2023
Fixes #3677

This CL also cleans up an old TODO.

RELNOTES=Fixes #3677: Better error messages for invalid @Multibinds types.
PiperOrigin-RevId: 500752608
@ZacSweers
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants