aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-05 02:56:06 +0200
committerMartin Odersky <odersky@gmail.com>2014-09-05 02:57:00 +0200
commitdc02760eac04accb9e0d5e34128f4c79cfa8c327 (patch)
tree1b048975e008a02ca7832a93cff2c987981a2cbb /src/dotty/tools/dotc/core/Types.scala
parent652a7e5d5a1db429a7270049d51ca63f494ee64b (diff)
downloaddotty-dc02760eac04accb9e0d5e34128f4c79cfa8c327.tar.gz
dotty-dc02760eac04accb9e0d5e34128f4c79cfa8c327.tar.bz2
dotty-dc02760eac04accb9e0d5e34128f4c79cfa8c327.zip
Partially reverting of 08c6eaca
Partial revert of 08c6eaca "this type is a term ref to the source module". The problem with doing this is that it introduces spurious outer references. An inner module that contains self referenves always needs the directly enclosing class. The revert avoids this dependency by making ThisTypes always point to TypeRefs. Several other changes were necessary to make the builds pass: TypeRefs had to get prefixes after erasure so that they can be reloaded. Symbols of such typerefs had to be retrieved without forcing a denotation. One test (blockescapes.scala) fails and is moved to pending, awaiting further resolution. Also two other new tests in pending which currently fail (and have failed before).
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 33a8d4be1..a2cf734ba 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1253,6 +1253,14 @@ object Types {
else denot.symbol
}
+ /** Retrieves currently valid symbol without necessarily updating denotation.
+ * Assumes that symbols do not change between periods in the same run.
+ * Used to get the class underlying a ThisType.
+ */
+ private[Types] def stableInRunSymbol(implicit ctx: Context): Symbol =
+ if (checkedPeriod.runId == ctx.runId) lastSymbol
+ else symbol
+
def info(implicit ctx: Context): Type = denot.info
def isType = isInstanceOf[TypeRef]
@@ -1526,7 +1534,7 @@ object Types {
object TypeRef {
/** Create type ref with given prefix and name */
def apply(prefix: Type, name: TypeName)(implicit ctx: Context): TypeRef =
- ctx.uniqueNamedTypes.enterIfNew(atCurrentPhase(prefix), name).asInstanceOf[TypeRef]
+ ctx.uniqueNamedTypes.enterIfNew(prefix, name).asInstanceOf[TypeRef]
/** Create type ref to given symbol */
def apply(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
@@ -1536,7 +1544,7 @@ object Types {
* with given prefix, name, and symbol.
*/
def withNonMemberSym(prefix: Type, name: TypeName, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
- unique(new NonMemberTypeRef(atCurrentPhase(prefix), name, sym))
+ unique(new NonMemberTypeRef(prefix, name, sym))
/** Create a type ref referring to given symbol with given name.
* This is very similar to TypeRef(Type, Symbol),
@@ -1545,12 +1553,12 @@ object Types {
* (2) The name in the type ref need not be the same as the name of the Symbol.
*/
def withSymAndName(prefix: Type, sym: TypeSymbol, name: TypeName)(implicit ctx: Context): TypeRef =
- if (isMissing(prefix)) withNonMemberSym(prefix, name, sym)
+ if (prefix eq NoPrefix) withNonMemberSym(prefix, name, sym)
else apply(prefix, name).withSym(sym, Signature.NotAMethod)
/** Create a type ref with given name and initial denotation */
def apply(prefix: Type, name: TypeName, denot: Denotation)(implicit ctx: Context): TypeRef =
- (if (isMissing(prefix)) apply(prefix, denot.symbol.asType) else apply(prefix, name)) withDenot denot
+ (if (prefix eq NoPrefix) apply(prefix, denot.symbol.asType) else apply(prefix, name)) withDenot denot
}
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
@@ -1561,7 +1569,7 @@ object Types {
* do not survive runs whereas typerefs do.
*/
abstract case class ThisType(tref: TypeRef) extends CachedProxyType with SingletonType {
- def cls(implicit ctx: Context): ClassSymbol = tref.symbol.asClass
+ def cls(implicit ctx: Context): ClassSymbol = tref.stableInRunSymbol.asClass
override def underlying(implicit ctx: Context): Type =
if (ctx.erasedTypes) tref else cls.classInfo.selfType
override def computeHash = doHash(tref)