diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 8ede7ba831f5..387c0f1d5d42 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)) @@ -602,7 +602,7 @@ object SpaceEngine { if (arity > 0) productSelectorTypes(resTp, unappSym.srcPos) else { - val getTp = extractorMemberType(resTp, nme.get, unappSym.srcPos) + val getTp = extractorMemberType(resTp, nme.get, unappSym.srcPos).stripNamedTuple if (argLen == 1) getTp :: Nil else productSelectorTypes(getTp, unappSym.srcPos) } diff --git a/tests/pos/i23158a.scala b/tests/pos/i23158a.scala new file mode 100644 index 000000000000..228721329701 --- /dev/null +++ b/tests/pos/i23158a.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(_, _) => ??? + } +} diff --git a/tests/pos/i23158b.scala b/tests/pos/i23158b.scala new file mode 100644 index 000000000000..e186592be92c --- /dev/null +++ b/tests/pos/i23158b.scala @@ -0,0 +1,11 @@ +//> using options -Werror + +object Unpack { + final case class Pair(a: Int, b: Int) + def unapply(e: Pair): (a: Int, b: Int) = ??? + + val x: Pair = ??? + x match { + case Unpack(_, _) => ??? + } +} diff --git a/tests/pos/i23158c.scala b/tests/pos/i23158c.scala new file mode 100644 index 000000000000..abe6ea90d7d2 --- /dev/null +++ b/tests/pos/i23158c.scala @@ -0,0 +1,11 @@ +//> using options -Werror + +object Unpack { + final case class Pair(a: Int, b: Int) + def unapply(e: Pair): Some[(a: Int, b: Int)] = ??? + + val x: Pair = ??? + x match { + case Unpack(_, _) => ??? + } +}