diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 7857f8c86189..12a739886925 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -581,7 +581,7 @@ object SpaceEngine { var resTp0 = mt.resultType if mt.isResultDependent then resTp0 = ctx.typeAssigner.safeSubstParam(resTp0, mt.paramRefs.head, scrutineeTp) - val resTp = wildApprox(resTp0.finalResultType) + val resTp = wildApprox(resTp0.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(_, _) => ??? + } +}