-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #6314: match type unsoundness #6319
Merged
Merged
Conversation
This file contains 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
OlivierBlanvillain
force-pushed
the
fix-6314
branch
2 times, most recently
from
April 29, 2019 15:07
249af27
to
ad3b0d0
Compare
Seams to be a leftover from scalac old pattern matcher and has always been dead code in dotty.
Singleton is not part of the normal type hierarchy, special treatment in requiered in intersecting to avoid making incorrect assumptions.
It timed out on my machine...
This breaks tests/run/typeclass-derivation2c.scala There is no way to statically know that the type passed to constValue reduces.
OlivierBlanvillain
force-pushed
the
fix-6314
branch
from
April 29, 2019 15:22
ad3b0d0
to
0cec095
Compare
OlivierBlanvillain
changed the title
Fix #6314: don't assume types in & are sorted
Fix #6314: match type unsoundness
Apr 30, 2019
odersky
requested changes
May 7, 2019
SeklomType are already mapped over correctly, that is, as .info.
OlivierBlanvillain
force-pushed
the
fix-6314
branch
from
May 16, 2019 15:31
a0819cd
to
74ca923
Compare
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.
This PR fixes several match issues
The first issue was that the algorithm assumes types in an
AndType
always came in the same order, so it wrongly concluded thatX & Y
andY & Type
are non intersecting from the fact thatX
andY
are non intersecting. The updated logic checks both permutations, and simply get stuck whenType
is abstract, which fixes the unsoundness.The second issue is related to the
Singleton
. This marker type needs to be taken it into account by the intersection algorithm, see the added test case.Finally the previous handling of abstract type was problematic a showed by several of the examples in #6314. The logic is updated to do a sub-type check where all the abstract types (members or parameters) are replace by
WildcardType
. If the scrutinee is not a subtype of a pattern, but it is with wildcards, then the type shouldn't reduce.