diff --git a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala index d311f3d981d8..6974f7f1b836 100644 --- a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala +++ b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala @@ -248,7 +248,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds, NoType case tp: TypeBounds => val lo1 = stripParams(tp.lo, todos, !isUpper).orElse(defn.NothingType) - val hi1 = stripParams(tp.hi, todos, isUpper).orElse(defn.AnyKindType) + val hi1 = stripParams(tp.hi, todos, isUpper).orElse(tp.topType) tp.derivedTypeBounds(lo1, hi1) case tp: AndType if isUpper => val tp1 = stripParams(tp.tp1, todos, isUpper) diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index da1817090d7a..862e1b698a28 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -229,7 +229,11 @@ class TypeApplications(val self: Type) extends AnyVal { (alias ne self) && alias.hasSimpleKind } - /** The top type with the same kind as `self`. */ + /** The top type with the same kind as `self`. This is largest type capturing + * the parameter shape of a type without looking at precise bounds. + * - The top-type of simple-kinded types is Any + * - A kind like (* -> *) -> * is represented by the top type [X1 <: [X2] =>> Any] =>> Any + */ def topType(using Context): Type = if self.hasSimpleKind then defn.AnyType diff --git a/tests/pos/i14760.scala b/tests/pos/i14760.scala new file mode 100644 index 000000000000..a913361c83eb --- /dev/null +++ b/tests/pos/i14760.scala @@ -0,0 +1,5 @@ +enum SUB[-A, +B]: + case Refl[X]() extends SUB[X, X] + +def foo[C, A >: C <: C, B](e: SUB[B, A]) = e match + case SUB.Refl() => \ No newline at end of file