diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 8a6fbd431ce9..b7d949864ab8 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -579,7 +579,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling case info2: TypeBounds => def compareGADT: Boolean = tp2.symbol.onGadtBounds(gbounds2 => - isSubTypeWhenFrozen(tp1, gbounds2.lo) + isSubType(tp1, gbounds2.lo, whenFrozen = gbounds2.lo ne gbounds2.hi) || tp1.match case tp1: NamedType if ctx.gadt.contains(tp1.symbol) => // Note: since we approximate constrained types only with their non-param bounds, @@ -964,7 +964,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling case info1 @ TypeBounds(lo1, hi1) => def compareGADT = tp1.symbol.onGadtBounds(gbounds1 => - isSubTypeWhenFrozen(gbounds1.hi, tp2) + isSubType(gbounds1.hi, tp2, whenFrozen = gbounds1.lo ne gbounds1.hi) || narrowGADTBounds(tp1, tp2, approx, isUpper = true)) && (tp2.isAny || GADTusage(tp1.symbol)) diff --git a/tests/pos/i23925.scala b/tests/pos/i23925.scala new file mode 100644 index 000000000000..9f923df9d99d --- /dev/null +++ b/tests/pos/i23925.scala @@ -0,0 +1,12 @@ +object test { + sealed trait A[T] + case class O[T](e: A[T]) extends A[Option[T]] + + def opt[U](v: Option[U], a: A[U]) = ??? + + def f[T](a: A[T], t: T) = { + a match { + case O(i) => opt(t, i) + } + } +}