Skip to content

Commit ed71954

Browse files
authored
Avoid crash in uninhab check in Space (#22601)
Fixes #22518
2 parents 41d4762 + 899d407 commit ed71954

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ object SpaceEngine {
674674
val superType = child.typeRef.superType
675675
if typeArgs.exists(_.isBottomType) && superType.isInstanceOf[ClassInfo] then
676676
val parentClass = superType.asInstanceOf[ClassInfo].declaredParents.find(_.classSymbol == parent).get
677-
val paramTypeMap = Map.from(parentClass.argTypes.map(_.typeSymbol).zip(typeArgs))
677+
val paramTypeMap = Map.from(parentClass.argInfos.map(_.typeSymbol).zip(typeArgs))
678678
val substArgs = child.typeRef.typeParamSymbols.map(param => paramTypeMap.getOrElse(param, WildcardType))
679679
substArgs
680680
else Nil

tests/pos/i22518.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sealed trait Foo[T]
2+
class Bar extends Foo[?]
3+
4+
def mkFoo[T]: Foo[T] =
5+
???
6+
7+
def test: Unit =
8+
mkFoo match
9+
case _ => ()

0 commit comments

Comments
 (0)