Skip to content

Commit c2a7bf5

Browse files
committed
use topType instead of kind
topType already does what we need here, and it is also correct for classes.
1 parent eae8920 commit c2a7bf5

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
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(tp.kind)
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

Lines changed: 5 additions & 14 deletions
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
@@ -258,19 +262,6 @@ class TypeApplications(val self: Type) extends AnyVal {
258262
case _ => NoType
259263
}
260264

261-
/** The kind of a type is the largest type capturing the parameter shape
262-
* of a type without looking at precise bounds.
263-
* - The kind of single-kinded types is Any
264-
* - A kind like (* -> *) -> * is represented as [X1 <: [X2] =>> Any] =>> Any
265-
*/
266-
def kind(using Context): Type = self.hkResult match
267-
case NoType => defn.AnyType
268-
case self: TypeRef if self.symbol == defn.AnyKindClass => self
269-
case rt =>
270-
HKTypeLambda(
271-
self.typeParams.map(tparam => TypeBounds.upper(tparam.paramInfo.hiBound.kind)),
272-
rt.kind)
273-
274265
/** Do self and other have the same kinds (not counting bounds and variances)?
275266
* Note: An any-kinded type "has the same kind" as any other type.
276267
*/

0 commit comments

Comments
 (0)