diff options
author | Martin Odersky <odersky@gmail.com> | 2013-01-31 18:50:31 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-01-31 18:50:31 +0100 |
commit | 4faeeceffdbc8dec9dd53bf299174a13d6bf87d0 (patch) | |
tree | 460926a8ed0df1bbb44c192630676854b0a5a29f /src/dotty/tools | |
parent | 340477017cea9dee6dff06f976cc1a42bb858671 (diff) | |
download | dotty-4faeeceffdbc8dec9dd53bf299174a13d6bf87d0.tar.gz dotty-4faeeceffdbc8dec9dd53bf299174a13d6bf87d0.tar.bz2 dotty-4faeeceffdbc8dec9dd53bf299174a13d6bf87d0.zip |
Generalized no-prefix types to types that can refer to an arbitrary fixed symbol.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 41405319a..459f219ac 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -613,15 +613,18 @@ object Types { abstract case class TypeRef(override val prefix: Type, name: TypeName) extends NamedType - trait NamedNoPrefix extends NamedType { + trait HasFixedSym extends NamedType { protected val fixedSym: Symbol override def symbol(implicit ctx: Context): Symbol = fixedSym - override def info(implicit ctx: Context): Type = fixedSym.info - override def denot(implicit ctx: Context): Denotation = fixedSym.denot + override def loadDenot(implicit ctx: Context) = { + val denot = fixedSym.denot + val owner = denot.owner + if (owner.isTerm) denot else denot.asSeenFrom(prefix, owner).toDenot + } } - final class TermRefNoPrefix(val fixedSym: TermSymbol)(implicit ctx: Context) - extends TermRef(NoPrefix, fixedSym.name) with NamedNoPrefix { + final class TermRefBySym(prefix: Type, val fixedSym: TermSymbol)(implicit ctx: Context) + extends TermRef(prefix, fixedSym.name) with HasFixedSym { } final class TermRefWithSignature(prefix: Type, name: TermName, override val signature: Signature) extends TermRef(prefix, name) { @@ -630,8 +633,8 @@ object Types { super.loadDenot.atSignature(signature) } - final class TypeRefNoPrefix(val fixedSym: TypeSymbol)(implicit ctx: Context) - extends TypeRef(NoPrefix, fixedSym.name) with NamedNoPrefix { + final class TypeRefBySym(prefix: Type, val fixedSym: TypeSymbol)(implicit ctx: Context) + extends TypeRef(prefix, fixedSym.name) with HasFixedSym { } final class CachedTermRef(prefix: Type, name: TermName) extends TermRef(prefix, name) @@ -646,8 +649,8 @@ object Types { object TermRef { def apply(prefix: Type, name: TermName)(implicit ctx: Context) = unique(new CachedTermRef(prefix, name)) - def apply(sym: TermSymbol)(implicit ctx: Context) = - unique(new TermRefNoPrefix(sym)) + def apply(prefix: Type, sym: TermSymbol)(implicit ctx: Context) = + unique(new TermRefBySym(prefix, sym)) def apply(prefix: Type, name: TermName, signature: Signature)(implicit ctx: Context) = unique(new TermRefWithSignature(prefix, name, signature)) } @@ -655,8 +658,8 @@ object Types { object TypeRef { def apply(prefix: Type, name: TypeName)(implicit ctx: Context) = unique(new CachedTypeRef(prefix, name)) - def apply(sym: TypeSymbol)(implicit ctx: Context) = - unique(new TypeRefNoPrefix(sym)) + def apply(prefix: Type, sym: TypeSymbol)(implicit ctx: Context) = + unique(new TypeRefBySym(prefix, sym)) } // --- Other SingletonTypes: ThisType/SuperType/ConstantType --------------------------- |