From 4c91a0bf9d54fe4490f9992354b98605a3bec6c4 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 14 Feb 2025 10:01:21 +0000 Subject: [PATCH] Avoid crash in uninhab check in Space [Cherry-picked 899d4078a0d83ccdd8663a4ff11f79b1350e8a8e] --- .../src/dotty/tools/dotc/transform/patmat/Space.scala | 2 +- tests/pos/i22518.scala | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i22518.scala diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 9cf94877328b..8f015bcd5f42 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -655,7 +655,7 @@ object SpaceEngine { val superType = child.typeRef.superType if typeArgs.exists(_.isBottomType) && superType.isInstanceOf[ClassInfo] then val parentClass = superType.asInstanceOf[ClassInfo].declaredParents.find(_.classSymbol == parent).get - val paramTypeMap = Map.from(parentClass.argTypes.map(_.typeSymbol).zip(typeArgs)) + val paramTypeMap = Map.from(parentClass.argInfos.map(_.typeSymbol).zip(typeArgs)) val substArgs = child.typeRef.typeParamSymbols.map(param => paramTypeMap.getOrElse(param, WildcardType)) substArgs else Nil diff --git a/tests/pos/i22518.scala b/tests/pos/i22518.scala new file mode 100644 index 000000000000..d530159701c4 --- /dev/null +++ b/tests/pos/i22518.scala @@ -0,0 +1,9 @@ +sealed trait Foo[T] +class Bar extends Foo[?] + +def mkFoo[T]: Foo[T] = + ??? + +def test: Unit = + mkFoo match + case _ => ()