From cbcdbd6fb8c0bf372a61b4ddd5b6ce181964776d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 22 Aug 2013 09:27:34 +0200 Subject: Various bug fixes for typer. --- src/dotty/tools/dotc/core/Names.scala | 9 ++++++--- src/dotty/tools/dotc/core/StdNames.scala | 6 ++---- src/dotty/tools/dotc/core/Symbols.scala | 8 ++++++-- src/dotty/tools/dotc/core/Types.scala | 5 +++-- 4 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src/dotty/tools/dotc/core') diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala index 77be4843c..5439d2d17 100644 --- a/src/dotty/tools/dotc/core/Names.scala +++ b/src/dotty/tools/dotc/core/Names.scala @@ -106,7 +106,7 @@ object Names { /** Replace operator symbols by corresponding \$op_name's. */ def encode: Name = - if (this eq CONSTRUCTOR) this else NameTransformer.encode(this) + if (dontEncode(toTermName)) this else NameTransformer.encode(this) /** A more efficient version of concatenation */ def ++ (other: Name): ThisName = ++ (other.toString) @@ -320,8 +320,11 @@ object Names { /** The type name represented by the empoty string */ val EmptyTypeName = EmptyTermName.toTypeName - // can't use nme.CONSTRUCTOR in encode because of bootstrap failures. - private val CONSTRUCTOR = termName("") + // can't move CONSTRUCTOR/EMPTY_PACKAGE to `nme` because of bootstrap failures in `encode`. + val CONSTRUCTOR = termName("") + val EMPTY_PACKAGE = termName("") + + val dontEncode = Set(CONSTRUCTOR, EMPTY_PACKAGE) def termNameBuilder: Builder[Char, TermName] = StringBuilder.newBuilder.mapResult(termName) diff --git a/src/dotty/tools/dotc/core/StdNames.scala b/src/dotty/tools/dotc/core/StdNames.scala index 9ae4729f4..e9fea8148 100644 --- a/src/dotty/tools/dotc/core/StdNames.scala +++ b/src/dotty/tools/dotc/core/StdNames.scala @@ -94,7 +94,7 @@ object StdNames { val DEFAULT_GETTER_INIT: N = encode("") val DO_WHILE_PREFIX: N = "doWhile$" val EMPTY: N = "" - val EMPTY_PACKAGE: N = "" + val EMPTY_PACKAGE: N = Names.EMPTY_PACKAGE.toString val EVIDENCE_PARAM_PREFIX: N = "evidence$" val EXCEPTION_RESULT_PREFIX: N = "exceptionResult" val EXPAND_SEPARATOR: N = "$$" @@ -212,7 +212,7 @@ object StdNames { // Compiler-internal val ANYname: N = "" - val CONSTRUCTOR: N = "" + val CONSTRUCTOR: N = Names.CONSTRUCTOR.toString val DEFAULT_CASE: N = "defaultCase$" val EQEQ_LOCAL_VAR: N = "eqEqTemp$" val FAKE_LOCAL_THIS: N = "this$" @@ -276,8 +276,6 @@ object StdNames { val ArrayAnnotArg: N = "ArrayAnnotArg" val Constant: N = "Constant" val ConstantType: N = "ConstantType" - val EmptyPackage: N = "EmptyPackage" - val EmptyPackageClass: N = "EmptyPackageClass" val ExistentialTypeTree: N = "ExistentialTypeTree" val Flag : N = "Flag" val HigherKinded: N = "HigherKinded" diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index ac13381e6..72dcef082 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -318,10 +318,14 @@ object Symbols { denot } - /** The run-id when this symbol was last defined */ - final def defRunId: RunId = + private def defRunId: RunId = if (lastDenot == null) NoRunId else lastDenot.validFor.runId + /** Does this symbol come from a currently compiled source file? */ + final def isDefinedInCurrentRun(implicit ctx: Context): Boolean = { + pos.exists && defRunId == ctx.runId + } + /** Subclass tests and casts */ final def isTerm(implicit ctx: Context): Boolean = denot.isTerm final def isType(implicit ctx: Context): Boolean = denot.isType diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 94810a2a2..63ce59995 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -193,6 +193,7 @@ object Types { /** The type symbol associated with the type */ final def typeSymbol(implicit ctx: Context): Symbol = this match { case tp: TypeRef => tp.symbol + case tp: TermRef => NoSymbol case tp: ClassInfo => tp.cls case ThisType(cls) => cls case tp: TypeProxy => tp.underlying.typeSymbol @@ -492,10 +493,10 @@ object Types { } /** The basetype of this type with given class symbol */ - final def baseType(base: Symbol)(implicit ctx: Context): Type = base.denot match { + final def baseType(base: Symbol)(implicit ctx: Context): Type = ctx.traceIndented(s"$this baseType $base") { base.denot match { case classd: ClassDenotation => classd.baseTypeOf(this) case _ => NoType - } + }} def & (that: Type)(implicit ctx: Context): Type = ctx.glb(this, that) -- cgit v1.2.3