@@ -255,7 +255,7 @@ object Types {
255255 case tp : NamedType => tp.info.isTightPrefix(sym)
256256 case tp : ClassInfo => tp.cls eq sym
257257 case tp : Types .ThisType => tp.cls eq sym
258- case tp : TypeProxy => tp.underlying .isTightPrefix(sym)
258+ case tp : TypeProxy => tp.superType .isTightPrefix(sym)
259259 case tp : AndType => tp.tp1.isTightPrefix(sym) && tp.tp2.isTightPrefix(sym)
260260 case tp : OrType => tp.tp1.isTightPrefix(sym) || tp.tp2.isTightPrefix(sym)
261261 case _ => false
@@ -331,7 +331,7 @@ object Types {
331331 val sym = tp.symbol
332332 if (sym.isClass) sym == defn.AnyKindClass else loop(tp.translucentSuperType)
333333 case tp : TypeProxy =>
334- loop(tp.underlying)
334+ loop(tp.underlying) // underlying OK here since an AnyKinded type cannot be a type argument of another type
335335 case _ =>
336336 false
337337 }
@@ -342,6 +342,7 @@ object Types {
342342 final def isNotNull (using Context ): Boolean = this match {
343343 case tp : ConstantType => tp.value.value != null
344344 case tp : ClassInfo => ! tp.cls.isNullableClass && tp.cls != defn.NothingClass
345+ case tp : AppliedType => tp.superType.isNotNull
345346 case tp : TypeBounds => tp.lo.isNotNull
346347 case tp : TypeProxy => tp.underlying.isNotNull
347348 case AndType (tp1, tp2) => tp1.isNotNull || tp2.isNotNull
@@ -501,7 +502,7 @@ object Types {
501502 val sym = tp.symbol
502503 if (sym.isClass) sym else tp.superType.classSymbol
503504 case tp : TypeProxy =>
504- tp.underlying .classSymbol
505+ tp.superType .classSymbol
505506 case tp : ClassInfo =>
506507 tp.cls
507508 case AndType (l, r) =>
@@ -535,7 +536,7 @@ object Types {
535536 val sym = tp.symbol
536537 if (include(sym)) sym :: Nil else tp.superType.parentSymbols(include)
537538 case tp : TypeProxy =>
538- tp.underlying .parentSymbols(include)
539+ tp.superType .parentSymbols(include)
539540 case tp : ClassInfo =>
540541 tp.cls :: Nil
541542 case AndType (l, r) =>
@@ -557,7 +558,7 @@ object Types {
557558 val sym = tp.symbol
558559 sym == cls || ! sym.isClass && tp.superType.hasClassSymbol(cls)
559560 case tp : TypeProxy =>
560- tp.underlying .hasClassSymbol(cls)
561+ tp.superType .hasClassSymbol(cls)
561562 case tp : ClassInfo =>
562563 tp.cls == cls
563564 case AndType (l, r) =>
@@ -571,12 +572,14 @@ object Types {
571572 * bounds of type variables in the constraint.
572573 */
573574 def isMatchableBound (using Context ): Boolean = dealias match
574- case tp : TypeRef => tp.symbol == defn.MatchableClass
575+ case tp : TypeRef =>
576+ val sym = tp.symbol
577+ sym == defn.MatchableClass || ! sym.isClass && tp.superType.isMatchableBound
575578 case tp : TypeParamRef =>
576579 ctx.typerState.constraint.entry(tp) match
577580 case bounds : TypeBounds => bounds.hi.isMatchableBound
578581 case _ => false
579- case tp : TypeProxy => tp.underlying .isMatchableBound
582+ case tp : TypeProxy => tp.superType .isMatchableBound
580583 case tp : AndType => tp.tp1.isMatchableBound || tp.tp2.isMatchableBound
581584 case tp : OrType => tp.tp1.isMatchableBound && tp.tp2.isMatchableBound
582585 case _ => false
0 commit comments