From 7e1343e86a0d2575d596198d0f889b7d64cdb5a4 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 20 Mar 2014 10:06:31 +0100 Subject: Refactored lookupRefined Turned parameter into receiver (reciever was not used before at all). --- src/dotty/tools/dotc/core/TypeComparer.scala | 4 ++-- src/dotty/tools/dotc/core/Types.scala | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/dotty/tools') diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 753a72dd0..d66d4069c 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -640,14 +640,14 @@ class TypeComparer(initctx: Context) extends DotClass { * if it is not instantiated we compare type parameter bounds * and also compare variances. */ - def isSubTypeHK(tp1: Type, tp2: Type): Boolean = ctx.traceIndented(s"isSubTypeHK(${tp1.show}, ${tp2.show}") { + def isSubTypeHK(tp1: Type, tp2: Type): Boolean = ctx.traceIndented(s"isSubTypeHK(${tp1.show}, ${tp2.show}", subtyping) { val tparams = tp1.typeParams val argInfos1 = tp1.argInfos val args1 = if (argInfos1.nonEmpty) argInfos1 // tp1 is instantiated, use the argument infos else { // tp1 is uninstantiated, use the parameter bounds val base = tp1.narrow - tparams.map(base.memberInfo) + tparams.map(base.memberInfo) } val hkArgs = tp2.argInfos hk.println(s"isSubTypeHK: args1 = $args1, hkargs = $hkArgs") diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 38c07d99a..e9c3c56b2 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -625,11 +625,11 @@ object Types { * * to just U */ - def lookupRefined(pre: Type, name: Name)(implicit ctx: Context): Type = pre.stripTypeVar match { + def lookupRefined(name: Name)(implicit ctx: Context): Type = stripTypeVar match { case pre: RefinedType => - if (pre.refinedName ne name) lookupRefined(pre.parent, name) + if (pre.refinedName ne name) pre.parent.lookupRefined(name) else pre.refinedInfo match { - case TypeBounds(lo, hi) if lo eq hi => hi + case TypeBounds(lo, hi) /*if lo eq hi*/ => hi case _ => NoType } case pre: WildcardType => @@ -643,7 +643,7 @@ object Types { case name: TermName => TermRef(this, name) case name: TypeName => - val res = lookupRefined(this, name) + val res = lookupRefined(name) if (res.exists) res else TypeRef(this, name) } @@ -652,7 +652,7 @@ object Types { case name: TermName => TermRef(this, name, denot) case name: TypeName => - val res = lookupRefined(this, name) + val res = lookupRefined(name) if (res.exists) res else TypeRef(this, name, denot) } @@ -660,7 +660,7 @@ object Types { def select(sym: Symbol)(implicit ctx: Context): Type = if (sym.isTerm) TermRef(this, sym.asTerm) else { - val res = lookupRefined(this, sym.name) + val res = lookupRefined(sym.name) if (res.exists) res else TypeRef(this, sym.asType) } @@ -1114,7 +1114,7 @@ object Types { def derivedSelect(prefix: Type)(implicit ctx: Context): Type = if (prefix eq this.prefix) this else { - val res = lookupRefined(prefix, name) + val res = prefix.lookupRefined(name) if (res.exists) res else newLikeThis(prefix) } @@ -2299,7 +2299,7 @@ object Types { case tp: TypeRef => if (stopAtStatic && tp.symbol.isStatic) x else { - val tp1 = tp.lookupRefined(tp.prefix, tp.name) + val tp1 = tp.prefix.lookupRefined(tp.name) this(x, if (tp1.exists) tp1 else tp.prefix) } case tp: TermRef => -- cgit v1.2.3