Skip to content

Commit 0493d5e

Browse files
authored
Merge pull request #464 from scala/backport-lts-3.3-23358
Backport "bugfix: Check for error before checking members of product type in getUnapplySelectors" to 3.3 LTS
2 parents a9920b0 + 712cc0e commit 0493d5e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ object Applications {
124124
}
125125

126126
def productSelectorTypes(tp: Type, errorPos: SrcPos)(using Context): List[Type] = {
127-
val sels = for (n <- Iterator.from(0)) yield extractorMemberType(tp, nme.selectorName(n), errorPos)
128-
sels.takeWhile(_.exists).toList
127+
if tp.isError then
128+
Nil
129+
else
130+
val sels = for (n <- Iterator.from(0)) yield extractorMemberType(tp, nme.selectorName(n), errorPos)
131+
sels.takeWhile(_.exists).toList
129132
}
130133

131134
def tupleComponentTypes(tp: Type)(using Context): List[Type] =

tests/neg/i23156.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Unpack {
2+
(1, 2) match {
3+
case Unpack(first, _) => first
4+
}
5+
def unapply(e: (Int, Int)): Option[T] = ??? // error
6+
}

0 commit comments

Comments
 (0)