Skip to content

Conversation

@OlivierBlanvillain
Copy link
Contributor

@OlivierBlanvillain OlivierBlanvillain commented Apr 16, 2019

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 that X & Y and Y & Type are non intersecting from the fact that X and Y are non intersecting. The updated logic checks both permutations, and simply get stuck when Type 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.

@OlivierBlanvillain OlivierBlanvillain force-pushed the fix-6314 branch 2 times, most recently from 249af27 to ad3b0d0 Compare April 29, 2019 15:07
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 OlivierBlanvillain changed the title Fix #6314: don't assume types in & are sorted Fix #6314: match type unsoundness Apr 30, 2019
@odersky odersky assigned OlivierBlanvillain and unassigned odersky May 7, 2019
SeklomType are already mapped over correctly, that is, as .info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants