From ef520ebf3f88db4a4dbb771f7fbeff71e3c749f6 Mon Sep 17 00:00:00 2001 From: aherlihy Date: Thu, 12 Jun 2025 18:44:18 +0200 Subject: [PATCH 1/5] Check for error type before checking members of product in getUnapplySelectors --- tests/pos/i23156.scala | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/pos/i23156.scala diff --git a/tests/pos/i23156.scala b/tests/pos/i23156.scala new file mode 100644 index 000000000000..35edef49bcc4 --- /dev/null +++ b/tests/pos/i23156.scala @@ -0,0 +1,6 @@ +object Unpack { + (1, 2) match { + case Unpack(first, _) => first + } + def unapply(e: (Int, Int)): Option[T] = ??? +} \ No newline at end of file From edc9d27e89b7ace8927b02426cdbf5f5d8b1098f Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 23 Jun 2025 16:31:05 +0200 Subject: [PATCH 2/5] Check for error type before checking members of product in getUnapplySelectors [Cherry-picked 248b9f1bee04e79c965d0c9498cea6ad9333be05][modified] From 8524b6990af8dcddb764cda3a2755ba1873dcd96 Mon Sep 17 00:00:00 2001 From: aherlihy Date: Thu, 12 Jun 2025 18:53:25 +0200 Subject: [PATCH 3/5] move test to neg [Cherry-picked af5d91129efd45883b8279fe0225540514bf2191] --- tests/{pos => neg}/i23156.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/{pos => neg}/i23156.scala (57%) diff --git a/tests/pos/i23156.scala b/tests/neg/i23156.scala similarity index 57% rename from tests/pos/i23156.scala rename to tests/neg/i23156.scala index 35edef49bcc4..c8f01ab16857 100644 --- a/tests/pos/i23156.scala +++ b/tests/neg/i23156.scala @@ -2,5 +2,5 @@ object Unpack { (1, 2) match { case Unpack(first, _) => first } - def unapply(e: (Int, Int)): Option[T] = ??? + def unapply(e: (Int, Int)): Option[T] = ??? // error } \ No newline at end of file From 6bf934c044fa23688572dca8232fab55503f8536 Mon Sep 17 00:00:00 2001 From: aherlihy Date: Fri, 13 Jun 2025 13:12:49 +0200 Subject: [PATCH 4/5] Move error check into productSelectorTypes --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index dbb3f7808dba..4d39e3243fc0 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -124,8 +124,11 @@ object Applications { } def productSelectorTypes(tp: Type, errorPos: SrcPos)(using Context): List[Type] = { - val sels = for (n <- Iterator.from(0)) yield extractorMemberType(tp, nme.selectorName(n), errorPos) - sels.takeWhile(_.exists).toList + if tp.isError then + Nil + else + val sels = for (n <- Iterator.from(0)) yield extractorMemberType(tp, nme.selectorName(n), errorPos) + sels.takeWhile(_.exists).toList } def tupleComponentTypes(tp: Type)(using Context): List[Type] = From 712cc0e3880a2f9520f82e7c167bbf924fc11c0e Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 23 Jun 2025 16:32:00 +0200 Subject: [PATCH 5/5] Move error check into productSelectorTypes [Cherry-picked 4c2f6b3666440a3beceec0062bf426ac66da45eb][modified]