diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 78e22b7b76b9..2b1f6394acdc 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1645,6 +1645,8 @@ object Types extends TypeUtils { pre.refinedInfo match { case tp: AliasingBounds => if (pre.refinedName ne name) loop(pre.parent) else tp.alias + case tp: SingletonType => + if pre.refinedName ne name then loop(pre.parent) else tp case _ => loop(pre.parent) } @@ -2676,11 +2678,8 @@ object Types extends TypeUtils { * refinement type `T { X = U; ... }` */ def reduceProjection(using Context): Type = - if (isType) { - val reduced = prefix.lookupRefined(name) - if (reduced.exists) reduced else this - } - else this + val reduced = prefix.lookupRefined(name) + if reduced.exists then reduced else this /** Guard against cycles that can arise if given `op` * follows info. The problematic cases are a type alias to itself or @@ -2765,14 +2764,14 @@ object Types extends TypeUtils { * (S | T)#A --> S#A | T#A */ def derivedSelect(prefix: Type)(using Context): Type = - if (prefix eq this.prefix) this - else if (prefix.isExactlyNothing) prefix + if prefix eq this.prefix then this + else if prefix.isExactlyNothing then prefix else { + val res = + if (isType && currentValidSymbol.isAllOf(ClassTypeParam)) argForParam(prefix) + else prefix.lookupRefined(name) + if (res.exists) return res if (isType) { - val res = - if (currentValidSymbol.isAllOf(ClassTypeParam)) argForParam(prefix) - else prefix.lookupRefined(name) - if (res.exists) return res if (Config.splitProjections) prefix match { case prefix: AndType => @@ -6563,7 +6562,7 @@ object Types extends TypeUtils { record(s"foldOver $getClass") record(s"foldOver total") tp match { - case tp: TypeRef => + case tp: NamedType => if stopBecauseStaticOrLocal(tp) then x else val tp1 = tp.prefix.lookupRefined(tp.name) @@ -6592,9 +6591,6 @@ object Types extends TypeUtils { variance = saved this(y, restpe) - case tp: TermRef => - if stopBecauseStaticOrLocal(tp) then x else applyToPrefix(x, tp) - case tp: TypeVar => this(x, tp.underlying)