Skip to content

Commit 54dc0c1

Browse files
authored
Merge pull request #14761 from dotty-staging/fix-14760
Keep correct kind when preparing constraint in stripParams
2 parents fb7f900 + c2a7bf5 commit 54dc0c1

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
248248
NoType
249249
case tp: TypeBounds =>
250250
val lo1 = stripParams(tp.lo, todos, !isUpper).orElse(defn.NothingType)
251-
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(defn.AnyKindType)
251+
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(tp.topType)
252252
tp.derivedTypeBounds(lo1, hi1)
253253
case tp: AndType if isUpper =>
254254
val tp1 = stripParams(tp.tp1, todos, isUpper)

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ class TypeApplications(val self: Type) extends AnyVal {
229229
(alias ne self) && alias.hasSimpleKind
230230
}
231231

232-
/** The top type with the same kind as `self`. */
232+
/** The top type with the same kind as `self`. This is largest type capturing
233+
* the parameter shape of a type without looking at precise bounds.
234+
* - The top-type of simple-kinded types is Any
235+
* - A kind like (* -> *) -> * is represented by the top type [X1 <: [X2] =>> Any] =>> Any
236+
*/
233237
def topType(using Context): Type =
234238
if self.hasSimpleKind then
235239
defn.AnyType

tests/pos/i14760.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enum SUB[-A, +B]:
2+
case Refl[X]() extends SUB[X, X]
3+
4+
def foo[C, A >: C <: C, B](e: SUB[B, A]) = e match
5+
case SUB.Refl() =>

0 commit comments

Comments
 (0)