Support map keys on contributed generic types and default bindings - #2592
Open
japplin wants to merge 2 commits into
Open
Support map keys on contributed generic types and default bindings #2592japplin wants to merge 2 commits into
japplin wants to merge 2 commits into
Conversation
Allow @ContributesIntoMap to derive map keys from generic type arguments or @DefaultBinding type parameters, including across modules. Implementation site keys take precedence over default keys. Reject conflicting key locations and multiple keyed type arguments.
Verify implicit class keys accept the concrete generic type used by @ContributesIntoMap and @DefaultBinding implementations. Reject multiple map keys on a generic argument and validate @DefaultBinding type parameter key uniqueness at the declaration site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds map key support for generic type arguments on
@ContributesIntoMapbindings and@DefaultBindingtype parameters.Default bindings can define the convention once:
Metro resolves the resulting entry as
HomeKey::classtoHomeScreen.Resolution behavior
Map keys are resolved in this order:
@DefaultBindingtype parameterThe default binding key is only a fallback. Keys declared by an implementation take precedence.
Metro reports an error when multiple declaration site locations provide a key or when multiple generic arguments or type parameters are annotated as map keys.
Metro also verifies that an implicit class key accepts the concrete generic type.
AI disclaimer: Most code and tests were generated with 5.6 Sol, I've done several passes of refactoring.