Skip to content

Commit d7a922a

Browse files
authored
Merge pull request #12424 from dotty-staging/fix-12408
Fix #12408: Parameterized classes should be applied for prefix inference
2 parents 50c0a61 + 7a28abd commit d7a922a

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,8 @@ object TypeOps:
769769
this(tref)
770770
else {
771771
prefixTVar = WildcardType // prevent recursive call from assigning it
772-
prefixTVar = newTypeVar(TypeBounds.upper(this(tref)))
772+
val tref2 = this(tref.applyIfParameterized(tref.typeParams.map(_ => TypeBounds.empty)))
773+
prefixTVar = newTypeVar(TypeBounds.upper(tref2))
773774
prefixTVar
774775
}
775776
case tp => mapOver(tp)

tests/patmat/i12408.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
13: Pattern Match Exhaustivity: A(_), C(_)
2+
21: Pattern Match

tests/patmat/i12408.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class X[T] {
2+
sealed trait P
3+
4+
case class A(id: Long) extends P
5+
case class B(id: Long, x: Long) extends P
6+
case class C(id: Long) extends P
7+
8+
def m(p: P): Unit = p match {
9+
case B(_, x) =>
10+
case _ =>
11+
}
12+
13+
def n(p: P): Unit = p match {
14+
case B(_, x) =>
15+
}
16+
17+
def o(p: P): Unit = p match {
18+
case A(_) =>
19+
case B(_, x) =>
20+
case C(_) =>
21+
case _ =>
22+
}
23+
24+
}

0 commit comments

Comments
 (0)