@@ -248,19 +248,6 @@ object Types {
248248 val d = defn
249249 hasClassSymbol(d.NothingClass ) || hasClassSymbol(d.NullClass )
250250
251- /** Does this type refer exactly to class symbol `sym`, instead of to a subclass of `sym`?
252- * Implemented like `isRef`, but follows more types: all type proxies as well as and- and or-types
253- */
254- private [Types ] def isTightPrefix (sym : Symbol )(using Context ): Boolean = stripTypeVar match {
255- case tp : NamedType => tp.info.isTightPrefix(sym)
256- case tp : ClassInfo => tp.cls eq sym
257- case tp : Types .ThisType => tp.cls eq sym
258- case tp : TypeProxy => tp.underlying.isTightPrefix(sym)
259- case tp : AndType => tp.tp1.isTightPrefix(sym) && tp.tp2.isTightPrefix(sym)
260- case tp : OrType => tp.tp1.isTightPrefix(sym) || tp.tp2.isTightPrefix(sym)
261- case _ => false
262- }
263-
264251 /** True if this type is an instance of the given `cls` or an instance of
265252 * a non-bottom subclass of `cls`.
266253 */
@@ -331,7 +318,7 @@ object Types {
331318 val sym = tp.symbol
332319 if (sym.isClass) sym == defn.AnyKindClass else loop(tp.translucentSuperType)
333320 case tp : TypeProxy =>
334- loop(tp.underlying)
321+ loop(tp.underlying) // underlying OK here since an AnyKinded type cannot be a type argument of another type
335322 case _ =>
336323 false
337324 }
@@ -342,6 +329,7 @@ object Types {
342329 final def isNotNull (using Context ): Boolean = this match {
343330 case tp : ConstantType => tp.value.value != null
344331 case tp : ClassInfo => ! tp.cls.isNullableClass && tp.cls != defn.NothingClass
332+ case tp : AppliedType => tp.superType.isNotNull
345333 case tp : TypeBounds => tp.lo.isNotNull
346334 case tp : TypeProxy => tp.underlying.isNotNull
347335 case AndType (tp1, tp2) => tp1.isNotNull || tp2.isNotNull
@@ -501,7 +489,7 @@ object Types {
501489 val sym = tp.symbol
502490 if (sym.isClass) sym else tp.superType.classSymbol
503491 case tp : TypeProxy =>
504- tp.underlying .classSymbol
492+ tp.superType .classSymbol
505493 case tp : ClassInfo =>
506494 tp.cls
507495 case AndType (l, r) =>
@@ -535,7 +523,7 @@ object Types {
535523 val sym = tp.symbol
536524 if (include(sym)) sym :: Nil else tp.superType.parentSymbols(include)
537525 case tp : TypeProxy =>
538- tp.underlying .parentSymbols(include)
526+ tp.superType .parentSymbols(include)
539527 case tp : ClassInfo =>
540528 tp.cls :: Nil
541529 case AndType (l, r) =>
@@ -557,7 +545,7 @@ object Types {
557545 val sym = tp.symbol
558546 sym == cls || ! sym.isClass && tp.superType.hasClassSymbol(cls)
559547 case tp : TypeProxy =>
560- tp.underlying .hasClassSymbol(cls)
548+ tp.superType .hasClassSymbol(cls)
561549 case tp : ClassInfo =>
562550 tp.cls == cls
563551 case AndType (l, r) =>
@@ -571,12 +559,14 @@ object Types {
571559 * bounds of type variables in the constraint.
572560 */
573561 def isMatchableBound (using Context ): Boolean = dealias match
574- case tp : TypeRef => tp.symbol == defn.MatchableClass
562+ case tp : TypeRef =>
563+ val sym = tp.symbol
564+ sym == defn.MatchableClass || ! sym.isClass && tp.superType.isMatchableBound
575565 case tp : TypeParamRef =>
576566 ctx.typerState.constraint.entry(tp) match
577567 case bounds : TypeBounds => bounds.hi.isMatchableBound
578568 case _ => false
579- case tp : TypeProxy => tp.underlying .isMatchableBound
569+ case tp : TypeProxy => tp.superType .isMatchableBound
580570 case tp : AndType => tp.tp1.isMatchableBound || tp.tp2.isMatchableBound
581571 case tp : OrType => tp.tp1.isMatchableBound && tp.tp2.isMatchableBound
582572 case _ => false
@@ -615,7 +605,7 @@ object Types {
615605 case tp : ClassInfo =>
616606 tp.decls
617607 case tp : TypeProxy =>
618- tp.underlying .decls
608+ tp.superType .decls
619609 case _ =>
620610 EmptyScope
621611 }
@@ -641,7 +631,7 @@ object Types {
641631 case tp : ClassInfo =>
642632 tp.decls.denotsNamed(name).filterWithFlags(EmptyFlags , excluded).toDenot(NoPrefix )
643633 case tp : TypeProxy =>
644- tp.underlying .findDecl(name, excluded)
634+ tp.superType .findDecl(name, excluded)
645635 case err : ErrorType =>
646636 newErrorSymbol(classSymbol orElse defn.RootClass , name, err.msg)
647637 case _ =>
@@ -885,7 +875,7 @@ object Types {
885875 def showPrefixSafely (pre : Type )(using Context ): String = pre.stripTypeVar match {
886876 case pre : TermRef => i " ${pre.symbol.name}. "
887877 case pre : TypeRef => i " ${pre.symbol.name}# "
888- case pre : TypeProxy => showPrefixSafely(pre.underlying )
878+ case pre : TypeProxy => showPrefixSafely(pre.superType )
889879 case _ => if (pre.typeSymbol.exists) i " ${pre.typeSymbol.name}# " else " ."
890880 }
891881
@@ -912,7 +902,7 @@ object Types {
912902 val ns = tp.parent.memberNames(keepOnly, pre)
913903 if (keepOnly(pre, tp.refinedName)) ns + tp.refinedName else ns
914904 case tp : TypeProxy =>
915- tp.underlying .memberNames(keepOnly, pre)
905+ tp.superType .memberNames(keepOnly, pre)
916906 case tp : AndType =>
917907 tp.tp1.memberNames(keepOnly, pre) | tp.tp2.memberNames(keepOnly, pre)
918908 case tp : OrType =>
@@ -1365,7 +1355,7 @@ object Types {
13651355 // which ensures that `X$ <:< X.type` returns true.
13661356 single(tp.symbol.companionModule.termRef.asSeenFrom(tp.prefix, tp.symbol.owner))
13671357 case tp : TypeProxy =>
1368- tp.underlying .atoms match
1358+ tp.superType .atoms match
13691359 case Atoms .Range (_, hi) => Atoms .Range (Set .empty, hi)
13701360 case Atoms .Unknown => Atoms .Unknown
13711361 case _ => Atoms .Unknown
@@ -1609,7 +1599,7 @@ object Types {
16091599 case tp : ClassInfo =>
16101600 tp.prefix
16111601 case tp : TypeProxy =>
1612- tp.underlying .normalizedPrefix
1602+ tp.superType .normalizedPrefix
16131603 case _ =>
16141604 NoType
16151605 }
0 commit comments