Skip to content

Commit 7e1343e

Browse files
oderskygzm0
authored andcommitted
Refactored lookupRefined
Turned parameter into receiver (reciever was not used before at all).
1 parent 0dda8a1 commit 7e1343e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,14 @@ class TypeComparer(initctx: Context) extends DotClass {
640640
* if it is not instantiated we compare type parameter bounds
641641
* and also compare variances.
642642
*/
643-
def isSubTypeHK(tp1: Type, tp2: Type): Boolean = ctx.traceIndented(s"isSubTypeHK(${tp1.show}, ${tp2.show}") {
643+
def isSubTypeHK(tp1: Type, tp2: Type): Boolean = ctx.traceIndented(s"isSubTypeHK(${tp1.show}, ${tp2.show}", subtyping) {
644644
val tparams = tp1.typeParams
645645
val argInfos1 = tp1.argInfos
646646
val args1 =
647647
if (argInfos1.nonEmpty) argInfos1 // tp1 is instantiated, use the argument infos
648648
else { // tp1 is uninstantiated, use the parameter bounds
649649
val base = tp1.narrow
650-
tparams.map(base.memberInfo)
650+
tparams.map(base.memberInfo)
651651
}
652652
val hkArgs = tp2.argInfos
653653
hk.println(s"isSubTypeHK: args1 = $args1, hkargs = $hkArgs")

src/dotty/tools/dotc/core/Types.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,11 @@ object Types {
625625
*
626626
* to just U
627627
*/
628-
def lookupRefined(pre: Type, name: Name)(implicit ctx: Context): Type = pre.stripTypeVar match {
628+
def lookupRefined(name: Name)(implicit ctx: Context): Type = stripTypeVar match {
629629
case pre: RefinedType =>
630-
if (pre.refinedName ne name) lookupRefined(pre.parent, name)
630+
if (pre.refinedName ne name) pre.parent.lookupRefined(name)
631631
else pre.refinedInfo match {
632-
case TypeBounds(lo, hi) if lo eq hi => hi
632+
case TypeBounds(lo, hi) /*if lo eq hi*/ => hi
633633
case _ => NoType
634634
}
635635
case pre: WildcardType =>
@@ -643,7 +643,7 @@ object Types {
643643
case name: TermName =>
644644
TermRef(this, name)
645645
case name: TypeName =>
646-
val res = lookupRefined(this, name)
646+
val res = lookupRefined(name)
647647
if (res.exists) res else TypeRef(this, name)
648648
}
649649

@@ -652,15 +652,15 @@ object Types {
652652
case name: TermName =>
653653
TermRef(this, name, denot)
654654
case name: TypeName =>
655-
val res = lookupRefined(this, name)
655+
val res = lookupRefined(name)
656656
if (res.exists) res else TypeRef(this, name, denot)
657657
}
658658

659659
/** The type <this . name> with given symbol, reduced if possible */
660660
def select(sym: Symbol)(implicit ctx: Context): Type =
661661
if (sym.isTerm) TermRef(this, sym.asTerm)
662662
else {
663-
val res = lookupRefined(this, sym.name)
663+
val res = lookupRefined(sym.name)
664664
if (res.exists) res else TypeRef(this, sym.asType)
665665
}
666666

@@ -1114,7 +1114,7 @@ object Types {
11141114
def derivedSelect(prefix: Type)(implicit ctx: Context): Type =
11151115
if (prefix eq this.prefix) this
11161116
else {
1117-
val res = lookupRefined(prefix, name)
1117+
val res = prefix.lookupRefined(name)
11181118
if (res.exists) res else newLikeThis(prefix)
11191119
}
11201120

@@ -2299,7 +2299,7 @@ object Types {
22992299
case tp: TypeRef =>
23002300
if (stopAtStatic && tp.symbol.isStatic) x
23012301
else {
2302-
val tp1 = tp.lookupRefined(tp.prefix, tp.name)
2302+
val tp1 = tp.prefix.lookupRefined(tp.name)
23032303
this(x, if (tp1.exists) tp1 else tp.prefix)
23042304
}
23052305
case tp: TermRef =>

0 commit comments

Comments
 (0)