do not apply subtype reduction if type set contains enum literals fro…#11368
Merged
Conversation
mhegazy
reviewed
Oct 4, 2016
| let sameEnumMembers = true; | ||
| for (let i = 1; i < types.length; i++) { | ||
| const other = types[i]; | ||
| if (!(other.flags & TypeFlags.EnumLiteral) || (getParentOfSymbol(first.symbol) !== getParentOfSymbol(other.symbol))) { |
Contributor
There was a problem hiding this comment.
you can propably cache this getParentOfSymbol(first.symbol)
mhegazy
approved these changes
Oct 4, 2016
ahejlsberg
reviewed
Oct 4, 2016
| if (sameEnumMembers) { | ||
| return; | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Maybe extract this logic into a separate isSetOfLiteralsFromSameEnum function and call that here. Otherwise, looks good to me.
Contributor
|
@vladima can we port this to release-2.0.5 |
vladima
added a commit
that referenced
this pull request
Oct 5, 2016
#11368) * do not apply subtype reduction if type set contains enum literals from the same enum * do not re-read symbol for the first enum * addressed PR feedback
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.
fix proposal for one of issues outlined in #10018.
repro case can boil down to:
We ended up with union types made of enum literals and spent most of the time doing subtype reduction which will not make any changes.
Proposal: make a pass over type set in question and check if all types are enum literal types that originate from the same enum. If check succeeded - skip subtype reduction part
Compilation time for code in test case:
// CC: @ahejlsberg