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

Permit Multibinds with MembersInjector values #4459

Closed

Conversation

damianw
Copy link

@damianw damianw commented Sep 25, 2024

The MultibindsMethodValidator prevents Multibinds methods from using Producer, Produced, Lazy, Provider, and MembersInjector as a Map value type or a Set element type. However, out of all of these, MembersInjector does not actually produce or access any instances; instead, it operates on an instance provided as an argument. Therefore, using it as a Map or Set value type is actually quite different than any of the rest.

It's actually already possible multi-bind a Set or Map with MembersInjector values, but not to declare such a binding with Multibinds. This PR changes the validator to allow such binding declarations, and adds additional tests to verify (and demonstrate) that this works as intended.

@Chang-Eric
Copy link
Member

Thanks for the PR and sorry for the delay here. Looking into this, I think we're actually just completely missing validation on the @IntoSet and @IntoMap types. I tried doing an @Provides @IntoMap that returns a Provider and it worked (or got farther than it should have), even though it really shouldn't be allowed.

I think it should be okay to allow MembersInjector though for maps, so what I'll do is I'll merge your PR in for the tests as disabled and then probably send a follow up to add the checking and enablement in?

@damianw
Copy link
Author

damianw commented Oct 10, 2024

Sounds great, thanks! Appreciate your looking into it.

copybara-service bot pushed a commit that referenced this pull request Oct 21, 2024
…omap.

Closes #4459.

RELNOTES=Permit @Multibinds with values that are also allowed by @IntoSet/@Intomap.
PiperOrigin-RevId: 684189777
@Chang-Eric
Copy link
Member

Also note the preceding change 15a30ca that adds validation for @IntoSet/@IntoMap bindings

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 this pull request may close these issues.

2 participants