Skip to content

Also reduce term projections #19389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down