diff options
author | Martin Odersky <odersky@gmail.com> | 2013-03-05 21:59:50 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-03-05 21:59:50 +0100 |
commit | 1e70081069055630821bb6ca6c1e307e1ab074b4 (patch) | |
tree | f02afc70f9e6412206adf649ecbc767393db7bcb /src/dotty/tools/dotc/core/TypeOps.scala | |
parent | 3efd95c6b2f9a0347edcdc14535ff6ed6dae054c (diff) | |
download | dotty-1e70081069055630821bb6ca6c1e307e1ab074b4.tar.gz dotty-1e70081069055630821bb6ca6c1e307e1ab074b4.tar.bz2 dotty-1e70081069055630821bb6ca6c1e307e1ab074b4.zip |
More polishing of types.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 82bd252f0..b81eb4a55 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -4,22 +4,18 @@ import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._ trait TypeOps { this: Context => - final def asSeenFrom(tp: Type, pre: Type, clazz: Symbol, theMap: AsSeenFromMap): Type = { + final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = { - def skipPrefixOf(pre: Type, clazz: Symbol) = - (pre eq NoType) || (pre eq NoPrefix) || clazz.isPackageClass - - def toPrefix(pre: Type, clazz: Symbol, thisclazz: ClassSymbol): Type = - if (skipPrefixOf(pre, clazz)) + def toPrefix(pre: Type, cls: Symbol, thiscls: ClassSymbol): Type = + if ((pre eq NoType) || (pre eq NoPrefix) || cls.isPackageClass) tp - else if ((thisclazz isNonBottomSubClass clazz) && - (pre.widen.typeSymbol isNonBottomSubClass thisclazz)) + else if (thiscls.isNonBottomSubClass(cls) && pre.baseType(thiscls).exists) pre match { case SuperType(thispre, _) => thispre case _ => pre } else - toPrefix(pre.baseType(clazz).normalizedPrefix, clazz.owner, thisclazz) + toPrefix(pre.baseType(cls).normalizedPrefix, cls.owner, thiscls) tp match { case tp: NamedType => @@ -27,7 +23,7 @@ trait TypeOps { this: Context => if (sym.isStatic) tp else { val pre0 = tp.prefix - val pre1 = asSeenFrom(pre0, pre, clazz, theMap) + val pre1 = asSeenFrom(pre0, pre, cls, theMap) if (pre1 eq pre0) tp else { val tp1 = NamedType(pre1, tp.name) @@ -43,23 +39,23 @@ trait TypeOps { this: Context => tp1 } } - case ThisType(thisclazz) => - toPrefix(pre, clazz, thisclazz) + case ThisType(thiscls) => + toPrefix(pre, cls, thiscls) case _: BoundType | NoPrefix => tp case tp: RefinedType => tp.derivedRefinedType( - asSeenFrom(tp.parent, pre, clazz, theMap), + asSeenFrom(tp.parent, pre, cls, theMap), tp.refinedName, - asSeenFrom(tp.refinedInfo, pre, clazz, theMap)) + asSeenFrom(tp.refinedInfo, pre, cls, theMap)) case _ => - (if (theMap != null) theMap else new AsSeenFromMap(pre, clazz)) + (if (theMap != null) theMap else new AsSeenFromMap(pre, cls)) .mapOver(tp) } } - class AsSeenFromMap(pre: Type, clazz: Symbol) extends TypeMap { - def apply(tp: Type) = asSeenFrom(tp, pre, clazz, this) + class AsSeenFromMap(pre: Type, cls: Symbol) extends TypeMap { + def apply(tp: Type) = asSeenFrom(tp, pre, cls, this) } final def isVolatile(tp: Type): Boolean = { |