Skip to content

Commit

Permalink
Fix scala#6687: handle gadtBounds in MT reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain committed Dec 15, 2020
1 parent 51c4f85 commit ece0c33
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
case _ => false
}


/** Are `tp1` and `tp2` provablyDisjoint types?
*
* `true` implies that we found a proof; uncertainty defaults to `false`.
Expand Down Expand Up @@ -2507,6 +2506,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
case (_, tp2: AndType) =>
!(tp2 <:< tp1)
&& (provablyDisjoint(tp1, tp2.tp2) || provablyDisjoint(tp1, tp2.tp1))
case (tp1: NamedType, _) if gadtBounds(tp1.symbol) != null =>
provablyDisjoint(gadtBounds(tp1.symbol).hi, tp2) || provablyDisjoint(tp1.superType, tp2)
case (_, tp2: NamedType) if gadtBounds(tp2.symbol) != null =>
provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
case (tp1: TypeProxy, tp2: TypeProxy) =>
provablyDisjoint(tp1.superType, tp2) || provablyDisjoint(tp1, tp2.superType)
case (tp1: TypeProxy, _) =>
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ i7087.scala
i7868.scala
i7872.scala
6709.scala
6687.scala

# Opaque type
i5720.scala
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/6687.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type T[X] = X match {
case String => Int
case Int => String
}

class Box[X](x: X)

def f[X](x: Box[X]): T[X] = x match {
case x: Box[Int] => ""
case x: Box[String] => 1
}

0 comments on commit ece0c33

Please sign in to comment.