Skip to content

Commit 83e9c14

Browse files
authored
bugfix: Check for error type in productSelectorTypes (#23358)
Fixes #23156
2 parents 372f889 + 4c2f6b3 commit 83e9c14

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
@@ -131,8 +131,11 @@ object Applications {
131131
else productSelectorTypes(tp, NoSourcePosition)
132132

133133
def productSelectorTypes(tp: Type, errorPos: SrcPos)(using Context): List[Type] = {
134-
val sels = for (n <- Iterator.from(0)) yield extractorMemberType(tp, nme.selectorName(n), errorPos)
135-
sels.takeWhile(_.exists).toList
134+
if tp.isError then
135+
Nil
136+
else
137+
val sels = for (n <- Iterator.from(0)) yield extractorMemberType(tp, nme.selectorName(n), errorPos)
138+
sels.takeWhile(_.exists).toList
136139
}
137140

138141
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)