diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index ab5885e6278c..d2b799c33f25 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -570,7 +570,7 @@ object SpaceEngine { // Case unapplySeq: // 1. return the type `List[T]` where `T` is the element type of the unapplySeq return type `Seq[T]` - val resTp = wildApprox(ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil).finalResultType) + val resTp = wildApprox(ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil).finalResultType).stripNamedTuple val sig = if (resTp.isRef(defn.BooleanClass)) diff --git a/tests/pos/i23158.scala b/tests/pos/i23158.scala new file mode 100644 index 000000000000..228721329701 --- /dev/null +++ b/tests/pos/i23158.scala @@ -0,0 +1,11 @@ +//> using options -Werror + +object Unpack { + final case class Pair(a: Int, b: Int) + def unapply(e: Pair): NamedTuple.NamedTuple[("a", "b"), (Int, Int)] = ??? + + val x: Pair = ??? + x match { + case Unpack(_, _) => ??? + } +}