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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalizedTupleTypedoes the opposite of what we want. We need to convertTupleNto*:equivalent. I found this function inTypeUtils.scalathat does exactly this:scala3/compiler/src/dotty/tools/dotc/core/TypeUtils.scala
Lines 122 to 126 in c82b623
Also note that
tp.normalizedonTupleNreturnsNoType.Using this function, the code is cleaner and more readable:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do the opposite?
TupleNneeds less object allocations.Maybe the following would work?
The above has the advantage that it always normalizes the type, even when it's a tuple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation of this issue is that the concatenation type of two tuples is made by a Match Type. When a
TupleNand another tuple were to be concatenated, the result type uses the*:equivalent. The resultingtypeSizeis larger and created a lot of false positives in the algorithm of PR #24661There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but from my understanding, the requirement is simply that both
TupleNand nested*:pairs be normalized to the same representation. Does it matter whetherTupleNis normalized to nested pairs, or vice versa? If we normalize toTupleN, then both types in the unit tests would have size1, wouldn't they?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess for your current implementation of match types termination checks, it's better if
(1, 2)and(1, 2, 3)have sizes2and3.