From cfab282e97dd66bba93049fbe665dd87c91b2689 Mon Sep 17 00:00:00 2001 From: Yoonjae Jeon Date: Fri, 19 Sep 2025 17:18:49 +0900 Subject: [PATCH] Call inhabited for AppliedType recursively --- .../tools/dotc/transform/patmat/Space.scala | 1 + tests/pos/i23734.scala | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/pos/i23734.scala diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 2baae092a1f3..7857f8c86189 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -702,6 +702,7 @@ object SpaceEngine { case OrType(tp1, tp2) => inhabited(tp1) || inhabited(tp2) case tp: RefinedType => inhabited(tp.parent) case tp: TypeRef => !containsUninhabitedField(tp) && inhabited(tp.prefix) + case tp: AppliedType => !containsUninhabitedField(tp) && inhabited(tp.tycon) case _ => !containsUninhabitedField(tp) if inhabited(refined) then refined diff --git a/tests/pos/i23734.scala b/tests/pos/i23734.scala new file mode 100644 index 000000000000..308bfdae3fa9 --- /dev/null +++ b/tests/pos/i23734.scala @@ -0,0 +1,18 @@ +trait Nodes1 { + sealed trait B + final case class R1() extends B +} + +trait Nodes2 extends Nodes1 { + final case class R2[T]() extends B +} + + +object Impl1 extends Nodes1 + +object test2 { + val a: Impl1.B = ??? + a match { + case Impl1.R1() => ??? + } +}