From 8c256ff44a7f995f4d6bed36735ef11cc38fe04d Mon Sep 17 00:00:00 2001 From: Emil Ejbyfeldt Date: Fri, 13 Jun 2025 16:05:05 +0200 Subject: [PATCH] Fix issue 23158 The fix is made based on us doing stripNamedTuple in other parts close by. Seems like made should in a single place, but I lack the bigger understanding to figure our where that would be. --- .../src/dotty/tools/dotc/transform/patmat/Space.scala | 2 +- tests/pos/i23158.scala | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i23158.scala 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(_, _) => ??? + } +}