@@ -380,7 +380,10 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
380380 if (cls2.typeParams.isEmpty) {
381381 if (cls2 eq AnyKindClass ) return true
382382 if (tp1.isRef(defn.NothingClass )) return true
383- if (tp1.isHK) return false
383+ if (tp1.isLambdaSub) return false
384+ // Note: We would like to replace this by `if (tp1.hasHigherKind)`
385+ // but right now we cannot since some parts of the standard library rely on the
386+ // idiom that e.g. `List <: Any`. We have to bootstrap without scalac first.
384387 val base = tp1.baseType(cls2)
385388 if (base.exists && base.ne(tp1))
386389 return isSubType(base, tp2, if (tp1.isRef(cls2)) approx else approx.addLow)
@@ -391,7 +394,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
391394 val base = tp1.baseType(cls2)
392395 if (base.typeSymbol == cls2) return true
393396 }
394- else if (tp1.isHK && ! tp1.isRef(defn.AnyKindClass ))
397+ else if (tp1.isLambdaSub && ! tp1.isRef(defn.AnyKindClass ))
395398 return recur(tp1, EtaExpansion (cls2.typeRef))
396399 }
397400 fourthTry
@@ -551,7 +554,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
551554 def compareTypeBounds = tp1 match {
552555 case tp1 @ TypeBounds (lo1, hi1) =>
553556 ((lo2 eq NothingType ) || isSubType(lo2, lo1)) &&
554- ((hi2 eq AnyType ) && ! hi1.isHK || (hi2 eq AnyKindType ) || isSubType(hi1, hi2))
557+ ((hi2 eq AnyType ) && ! hi1.isLambdaSub || (hi2 eq AnyKindType ) || isSubType(hi1, hi2))
555558 case tp1 : ClassInfo =>
556559 tp2 contains tp1
557560 case _ =>
@@ -621,7 +624,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
621624 case EtaExpansion (tycon1) => recur(tycon1, tp2)
622625 case _ => tp2 match {
623626 case tp2 : HKTypeLambda => false // this case was covered in thirdTry
624- case _ => tp2.isHK && isSubType(tp1.resultType, tp2.appliedTo(tp1.paramRefs))
627+ case _ => tp2.isLambdaSub && isSubType(tp1.resultType, tp2.appliedTo(tp1.paramRefs))
625628 }
626629 }
627630 compareHKLambda
@@ -729,7 +732,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
729732 tl => tp1base.tycon.appliedTo(args1.take(lengthDiff) ++
730733 tparams1.indices.toList.map(tl.paramRefs(_))))
731734 (ctx.mode.is(Mode .TypevarsMissContext ) ||
732- tryInstantiate(tycon2, tycon1.ensureHK )) &&
735+ tryInstantiate(tycon2, tycon1.ensureLambdaSub )) &&
733736 recur(tp1, tycon1.appliedTo(args2))
734737 }
735738 }
@@ -812,7 +815,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
812815 case param1 : TypeParamRef =>
813816 def canInstantiate = tp2 match {
814817 case AppliedType (tycon2, args2) =>
815- tryInstantiate(param1, tycon2.ensureHK ) && isSubArgs(args1, args2, tp1, tycon2.typeParams)
818+ tryInstantiate(param1, tycon2.ensureLambdaSub ) && isSubArgs(args1, args2, tp1, tycon2.typeParams)
816819 case _ =>
817820 false
818821 }
@@ -1227,8 +1230,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
12271230 if (tp1 eq tp2) tp1
12281231 else if (! tp1.exists) tp2
12291232 else if (! tp2.exists) tp1
1230- else if ((tp1 isRef AnyClass ) && ! tp2.isHK || (tp1 isRef AnyKindClass ) || (tp2 isRef NothingClass )) tp2
1231- else if ((tp2 isRef AnyClass ) && ! tp1.isHK || (tp2 isRef AnyKindClass ) || (tp1 isRef NothingClass )) tp1
1233+ else if ((tp1 isRef AnyClass ) && ! tp2.isLambdaSub || (tp1 isRef AnyKindClass ) || (tp2 isRef NothingClass )) tp2
1234+ else if ((tp2 isRef AnyClass ) && ! tp1.isLambdaSub || (tp2 isRef AnyKindClass ) || (tp1 isRef NothingClass )) tp1
12321235 else tp2 match { // normalize to disjunctive normal form if possible.
12331236 case OrType (tp21, tp22) =>
12341237 tp1 & tp21 | tp1 & tp22
0 commit comments