-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #10108: Distinguish between soft and hard union types #10112
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
Conversation
isSoft
flag in OrTypes5405907
to
f2aef39
Compare
9d879fb
to
da869ed
Compare
It turned out that it's generally clear whether an OrType should be soft or hard, so this is a good first step to solve the problem.
da869ed
to
24f2a6c
Compare
@liufengyun We get quite a few different check files in pattern matching. One problem is that an extra empty line got added in several of them. There are also two completely different outputs for tests involving hard union types. In one case, the check file is now 8MB long! I updated the check files in 248f9eb. Can you take a look at the failures, and possibly also revert 248f9eb? |
OK, I'll have a look and fix the exhaustivity check problems. |
It seems it's not needed since erasure already takes care of inserting the necessary casts
24f2a6c
to
d4791ef
Compare
- show at most 6 unmatched cases
d4791ef
to
0463200
Compare
@@ -18,7 +18,7 @@ import org.junit.Test | |||
class PatmatExhaustivityTest { | |||
val testsDir = "tests/patmat" | |||
// stop-after: patmatexhaust-huge.scala crash compiler | |||
val options = List("-color:never", "-Ystop-after:crossCast", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) | |||
val options = List("-color:never", "-Ystop-after:explicitSelf", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) |
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.
That explains the mystery of the added lines, I suppose? Good catch!
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.
Yes, most failures come from this change. The test case i8922c.scala
and i4030.scala
are due to type inference change.
|
||
ss.foldLeft(LazyList(Nil : List[Space])) { (acc, flat) => | ||
for { sps <- acc; s <- flat } | ||
yield sps :+ s |
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.
Nice!
Thanks for the fixes Fengyun! Your changes LGTM. Can you do the review for the rest? |
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.
LGTM
@@ -18,7 +18,7 @@ import org.junit.Test | |||
class PatmatExhaustivityTest { | |||
val testsDir = "tests/patmat" | |||
// stop-after: patmatexhaust-huge.scala crash compiler | |||
val options = List("-color:never", "-Ystop-after:crossCast", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) | |||
val options = List("-color:never", "-Ystop-after:explicitSelf", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) |
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.
Yes, most failures come from this change. The test case i8922c.scala
and i4030.scala
are due to type inference change.
@@ -9,5 +9,6 @@ object TestGADT { | |||
def f[A <: Seq[_], B, Foo >: A => B](v: Root[Foo], u: Root[Foo]) = (v, u) match { | |||
case (C3(), C3()) => | |||
} | |||
f(C3[Seq[_], Long](), C4[Seq[_], Long]()) | |||
// The following line no longer type checks | |||
// f(C3[Seq[_], Long](), C4[Seq[_], Long]()) |
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.
This test case shows that this PR improves over the previous handling of union types 👍
The new system widens only soft union types using a join. If a hard union type appears in a soft one, it is dissolved together with the soft union type. Unions with Null continue to be treated specially.