Skip to content

Commit d7c581c

Browse files
Fix #6687: handle gadtBounds in MT reduction
1 parent b9c984a commit d7c581c

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
@@ -2166,7 +2166,6 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
21662166
case _ => false
21672167
}
21682168

2169-
21702169
/** Are `tp1` and `tp2` provablyDisjoint types?
21712170
*
21722171
* `true` implies that we found a proof; uncertainty defaults to `false`.
@@ -2274,6 +2273,10 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
22742273
provablyDisjoint(tp1.tp2, tp2) || provablyDisjoint(tp1.tp1, tp2)
22752274
case (_, tp2: AndType) =>
22762275
provablyDisjoint(tp1, tp2.tp2) || provablyDisjoint(tp1, tp2.tp1)
2276+
case (tp1: NamedType, _) if gadtBounds(tp1.symbol) != null =>
2277+
provablyDisjoint(gadtBounds(tp1.symbol).hi, tp2) || provablyDisjoint(tp1.superType, tp2)
2278+
case (_, tp2: NamedType) if gadtBounds(tp2.symbol) != null =>
2279+
provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
22772280
case (tp1: TypeProxy, tp2: TypeProxy) =>
22782281
provablyDisjoint(tp1.superType, tp2) || provablyDisjoint(tp1, tp2.superType)
22792282
case (tp1: TypeProxy, _) =>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typelevel0.scala
2222
matchtype.scala
2323
6322.scala
2424
i7087.scala
25+
6687.scala
2526

2627
# Opaque type
2728
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)