From 01c99aa384b42e3d19bb7e8e0f7b85ea9102e199 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 26 Dec 2012 10:13:03 +0100 Subject: Added isStatic check to asSeenFrom --- src/dotty/tools/dotc/core/Types.scala | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/dotty/tools/dotc/core') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 92c0fe78a..591c7dddd 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -158,8 +158,6 @@ object Types { def prefix: Type = ??? - def isTrivial: Boolean = ??? - def resultType: Type = ??? def baseClasses(implicit ctx: Context): List[ClassSymbol] = @@ -170,19 +168,17 @@ object Types { def isCachable: Boolean = false def asSeenFrom(pre: Type, clazz: Symbol)(implicit ctx: Context): Type = - if (isTrivial || - ctx.erasedTypes && clazz != defn.ArrayClass || - clazz.isStaticMono) this + if (clazz.isStaticMono || ctx.erasedTypes && clazz != defn.ArrayClass ) this else asSeenFrom(pre, clazz, null) - def asSeenFrom(pre: Type, clazz: Symbol, map: AsSeenFromMap)(implicit ctx: Context): Type = { + def asSeenFrom(pre: Type, clazz: Symbol, theMap: AsSeenFromMap)(implicit ctx: Context): Type = { def skipPrefixOf(pre: Type, clazz: Symbol) = (pre eq NoType) || (pre eq NoPrefix) || clazz.isPackageClass - def toPrefix(pre: Type, clazz: Symbol, thisclazz: ClassSymbol, tp: Type): Type = + def toPrefix(pre: Type, clazz: Symbol, thisclazz: ClassSymbol): Type = if (skipPrefixOf(pre, clazz)) - tp + this else if ((thisclazz isNonBottomSubClass clazz) && (pre.widen.typeSymbol isNonBottomSubClass thisclazz)) pre match { @@ -190,10 +186,10 @@ object Types { case _ => pre } else - toPrefix(pre.baseType(clazz).prefix, clazz.owner, thisclazz, tp) + toPrefix(pre.baseType(clazz).prefix, clazz.owner, thisclazz) - def toInstance(pre: Type, clazz: Symbol, tparam: Symbol, tp: Type): Type = { - if (skipPrefixOf(pre, clazz)) tp + def toInstance(pre: Type, clazz: Symbol, tparam: Symbol): Type = { + if (skipPrefixOf(pre, clazz)) this else { val tparamOwner = tparam.owner @@ -224,21 +220,20 @@ object Types { else throwError if (tparamOwner == clazz && prefixMatches) instParamFrom(basePre) - else toInstance(basePre.prefix, clazz.owner, tparam, tp) + else toInstance(basePre.prefix, clazz.owner, tparam) } } this match { case tp: NamedType => val sym = tp.symbol - if (tp.symbol.isTypeParameter) - toInstance(pre, clazz, sym, this) - else - tp.derivedNamedType(tp.prefix.asSeenFrom(pre, clazz), tp.name) + if (tp.symbol.isTypeParameter) toInstance(pre, clazz, sym) + else if (sym.isStatic) this + else tp.derivedNamedType(tp.prefix.asSeenFrom(pre, clazz, theMap), tp.name) case ThisType(thisclazz) => - toPrefix(pre, clazz, thisclazz, this) + toPrefix(pre, clazz, thisclazz) case _ => - val asSeenFromMap = if (map != null) map else new AsSeenFromMap(pre, clazz) + val asSeenFromMap = if (theMap != null) theMap else new AsSeenFromMap(pre, clazz) this match { case tp: AppliedType => tp.derivedAppliedType( -- cgit v1.2.3