Skip to content

Commit 5b98c4f

Browse files
committed
Fix scala#9533: handle nested TypeParamRef in bounds
1 parent 22c23a5 commit 5b98c4f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,13 @@ final class ProperGadtConstraint private(
224224
override protected def isSame(tp1: Type, tp2: Type)(using Context): Boolean = TypeComparer.isSameType(tp1, tp2)
225225

226226
override def nonParamBounds(param: TypeParamRef)(using Context): TypeBounds =
227-
constraint.nonParamBounds(param) match {
228-
case TypeAlias(tpr: TypeParamRef) => TypeAlias(externalize(tpr))
229-
case tb => tb
227+
val externalizeMap = new TypeMap {
228+
def apply(tp: Type): Type = tp match {
229+
case tpr: TypeParamRef => externalize(tpr)
230+
case tp => mapOver(tp)
231+
}
230232
}
233+
externalizeMap(constraint.nonParamBounds(param)).bounds
231234

232235
override def fullLowerBound(param: TypeParamRef)(using Context): Type =
233236
constraint.minLower(param).foldLeft(nonParamBounds(param).lo) {

tests/pos/i9533.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Test {
2+
sealed trait Base[-X]
3+
case class Child[X]() extends Base[X]
4+
5+
def apply[A, B](r: Base[A with B]): Unit = {
6+
r match {
7+
case Child() => ()
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)