Skip to content

Commit 88c0b61

Browse files
Fix #6687: handle gadtBounds in MT reduction
1 parent 8ee680f commit 88c0b61

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
23882388
case _ => false
23892389
}
23902390

2391-
23922391
/** Are `tp1` and `tp2` provablyDisjoint types?
23932392
*
23942393
* `true` implies that we found a proof; uncertainty defaults to `false`.
@@ -2507,6 +2506,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25072506
case (_, tp2: AndType) =>
25082507
!(tp2 <:< tp1)
25092508
&& (provablyDisjoint(tp1, tp2.tp2) || provablyDisjoint(tp1, tp2.tp1))
2509+
case (tp1: NamedType, _) if gadtBounds(tp1.symbol) != null =>
2510+
provablyDisjoint(gadtBounds(tp1.symbol).hi, tp2) || provablyDisjoint(tp1.superType, tp2)
2511+
case (_, tp2: NamedType) if gadtBounds(tp2.symbol) != null =>
2512+
provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
25102513
case (tp1: TypeProxy, tp2: TypeProxy) =>
25112514
provablyDisjoint(tp1.superType, tp2) || provablyDisjoint(tp1, tp2.superType)
25122515
case (tp1: TypeProxy, _) =>

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ i7087.scala
3030
i7868.scala
3131
i7872.scala
3232
6709.scala
33+
6687.scala
3334

3435
# Opaque type
3536
i5720.scala

tests/pos/6687.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type T[X] = X match {
2+
case String => Int
3+
case Int => String
4+
}
5+
6+
class Box[X](x: X)
7+
8+
def f[X](x: Box[X]): T[X] = x match {
9+
case x: Box[Int] => ""
10+
case x: Box[String] => 1
11+
}

0 commit comments

Comments
 (0)