Skip to content

Commit c43caf5

Browse files
authored
Fix false exhaustivity for GADT under separate compilation (#23966)
fixes #23817
2 parents 4cd43dd + b591214 commit c43caf5

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ object SpaceEngine {
537537
scrutineeTp match
538538
case AppliedType(tycon, targs)
539539
if unappSym.is(Synthetic)
540-
&& (pt.resultType.asInstanceOf[MethodType].paramInfos.head.typeConstructor eq tycon) =>
540+
&& (pt.resultType.asInstanceOf[MethodType].paramInfos.head.typeConstructor =:= tycon) =>
541541
// Special case synthetic unapply/unapplySeq's
542542
// Provided the shapes of the types match:
543543
// the scrutinee type being unapplied and

tests/pos/i23817/file_1.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sealed trait N[T]
2+
case class MakeTuple[T <: Tuple](v: T) extends N[T]

tests/pos/i23817/file_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object test {
2+
def t[T](expr: N[T]): Any =
3+
expr match {
4+
case MakeTuple(_) => ???
5+
}
6+
}

tests/pos/i23817_2/file_1.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
trait TC2[X]
2+
sealed trait TC1[T]
3+
case class Iterable[T, C <: scala.Iterable[T]](tag: TC1[C]) extends TC1[C]

tests/pos/i23817_2/file_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object test {
2+
def f[T](c: TC1[T]): Unit =
3+
c match {
4+
case Iterable(_) => ???
5+
}
6+
}

0 commit comments

Comments
 (0)