Force inner indexed access simplification during inference, if possible#28420
Merged
weswigham merged 3 commits intomicrosoft:masterfrom Nov 12, 2018
Merged
Conversation
DanielRosenwasser
requested changes
Nov 9, 2018
DanielRosenwasser
approved these changes
Nov 12, 2018
|
|
||
| function distributeIndexOverObjectType(objectType: Type, indexType: Type) { | ||
| // (T | U)[K] -> T[K] | U[K] | ||
| if (objectType.flags & TypeFlags.Union) { |
Member
There was a problem hiding this comment.
You're a bad person for not testing this branch.
Member
Author
There was a problem hiding this comment.
Excuse me, I'm just reusing an operation already in use elsehwere ☑️
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #28394
This is effectively an extension of #27953 -
getSimplifiedTyperefrains from simplifying indexed accesses whose index is still generic, as it might later be instantiated and require outer distribution; however since we're in the middle of inference, we're just interested in breaking down our types as far as they'll go to find matching patterns; we're not concerned with thetargetside's ability to be further instantiated, since we're just looking for one of our goal type variables.