diff options
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymbolLoaders.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Trees.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 17 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 3 |
9 files changed, 45 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index ecb22f71a..241d41da9 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -48,7 +48,7 @@ object Contexts { with SymDenotations with Reporting with Cloneable { thiscontext => - implicit val ctx: Context = this + implicit def ctx: Context = this /** The context base at the root */ val base: ContextBase @@ -128,6 +128,13 @@ object Contexts { protected def diagnostics_=(diagnostics: Option[StringBuilder]) = _diagnostics = diagnostics def diagnostics: Option[StringBuilder] = _diagnostics + /** Should prefix of type selections to be checked whether it's stable? + * Disabled when reading Scala pickled information. + */ + private var _checkPrefix: Boolean = true + protected def checkPrefix_=(checkPrefix: Boolean) = _checkPrefix = checkPrefix + def checkPrefix: Boolean = _checkPrefix + /** Leave message in diagnostics buffer if it exists */ def diagnose(str: => String) = for (sb <- diagnostics) { @@ -206,6 +213,7 @@ object Contexts { def withTree(tree: Tree): this.type = { this.tree = tree; this } def withReporter(reporter: Reporter): this.type = { this.reporter = reporter; this } def withDiagnostics(diagnostics: Option[StringBuilder]): this.type = { this.diagnostics = diagnostics; this } + def withCheckPrefix(checkPrefix: Boolean): this.type = { this.checkPrefix = checkPrefix; this } def withPhase(pid: PhaseId): this.type = withPeriod(Period(runId, pid)) diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 8ac67dd02..81cdf4826 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -83,7 +83,12 @@ class Definitions(implicit ctx: Context) { lazy val PredefModule = requiredModule("scala.Predef") // lazy val FunctionClass: ClassSymbol = requiredClass("scala.Function") - lazy val SingletonClass: ClassSymbol = requiredClass("dotty.Singleton") + lazy val SingletonClass: ClassSymbol = + // needed as a synthetic class because Scala 2.x refers to it in classfiles + // but does not define it as an explicit class. + ctx.newCompleteClassSymbol( + ScalaPackageClass, tpnme.Singleton, Trait | Interface | Final, + List(AnyClass.typeConstructor), EmptyScope).entered lazy val SeqClass: ClassSymbol = requiredClass("scala.collection.Seq") lazy val ArrayClass: ClassSymbol = requiredClass("scala.Array") lazy val uncheckedStableClass: ClassSymbol = requiredClass("scala.annotation.unchecked.uncheckedStable") @@ -291,6 +296,7 @@ class Definitions(implicit ctx: Context) { AnyValClass, NullClass, NothingClass, + SingletonClass, EqualsPatternClass) private[this] var _isInitialized = false diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index f8837fafe..08f4c9c57 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -306,6 +306,7 @@ object Denotations { denot1.hasAltWith(p) || denot2.hasAltWith(p) def derivedMultiDenotation(d1: Denotation, d2: Denotation) = if ((d1 eq denot1) && (d2 eq denot2)) this else MultiDenotation(d1, d2) + override def toString = alternatives.mkString(" <and> ") } /** A non-overloaded denotation */ @@ -458,6 +459,10 @@ object Denotations { final def asSymDenotation = asInstanceOf[SymDenotation] + override def toString = + if (symbol == NoSymbol) symbol.toString + else s"<SingleDenotation of type $info>" + // ------ PreDenotation ops ---------------------------------------------- final def first = this diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index d39194bf1..85104f30f 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -167,7 +167,8 @@ object Scopes { /** enter a symbol in this scope. */ final def enter[T <: Symbol](sym: T)(implicit ctx: Context): T = { if (sym.isType) { - assert(lookup(sym.name) == NoSymbol, sym.debugString) // !!! DEBUG + assert(lookup(sym.name) == NoSymbol, + s"duplicate type ${sym.debugString}; previous was ${lookup(sym.name).debugString}") // !!! DEBUG } newScopeEntry(sym) sym diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala index f5c8bf999..ab177a92b 100644 --- a/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -287,7 +287,7 @@ class ClassfileLoader(val classfile: AbstractFile)(implicit val cctx: CondensedC def doComplete(root: SymDenotation) { val (classRoot, moduleRoot) = rootDenots(root.asClass) - new ClassfileParser(classfile, classRoot, moduleRoot).run() + new ClassfileParser(classfile, classRoot, moduleRoot)(cctx).run() } } diff --git a/src/dotty/tools/dotc/core/Trees.scala b/src/dotty/tools/dotc/core/Trees.scala index 5fcab4de7..922bf6055 100644 --- a/src/dotty/tools/dotc/core/Trees.scala +++ b/src/dotty/tools/dotc/core/Trees.scala @@ -28,7 +28,7 @@ object Trees { * - Type checking an untyped tree should remove all embedded `TypedSplice` * nodes. */ - abstract class Tree[T] extends DotClass with Showable { + abstract class Tree[T] extends DotClass with Showable with Cloneable { /** The tree's position. Except * for SharedTree nodes, it is always ensured that a tree's position diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 9f5a56df7..c349bc7ba 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -383,13 +383,8 @@ object Types { /** If this is an alias type, its alias, otherwise the type itself */ final def dealias(implicit ctx: Context): Type = this match { - case tp: TypeRef => - tp.info match { - case TypeBounds(lo, hi) if lo eq hi => hi.dealias - case _ => this - } - case _ => - this + case tp: TypeRef if (tp.symbol.isAliasType) => tp.info.bounds.hi + case _ => this } /** Widen from constant type to its underlying non-constant @@ -860,8 +855,10 @@ object Types { lastDenotation.current } else { val d = loadDenot - if (d.exists && !d.symbol.isAliasType && !prefix.isLegalPrefix) - throw new MalformedType(prefix, d.asInstanceOf[SymDenotation]) + if (d.exists && !d.symbol.isAliasType && !prefix.isLegalPrefix) { + val ex = new MalformedType(prefix, d) + if (ctx.checkPrefix) throw ex else ctx.log(ex.getMessage) + } if (d.exists || ctx.phaseId == FirstPhaseId) d else // name has changed; try load in earlier phase and make current @@ -1660,7 +1657,7 @@ object Types { class TypeError(msg: String) extends Exception(msg) class FatalTypeError(msg: String) extends TypeError(msg) - class MalformedType(pre: Type, denot: SymDenotation) + class MalformedType(pre: Type, denot: Denotation) extends FatalTypeError(s"malformed type: $pre is not a legal prefix for $denot") class CyclicReference(denot: SymDenotation) extends FatalTypeError(s"cyclic reference involving $denot") diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 11dcd2152..6b7721213 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -16,7 +16,9 @@ import io.AbstractFile class ClassfileParser( classfile: AbstractFile, classRoot: ClassDenotation, - moduleRoot: ClassDenotation)(implicit cctx: CondensedContext) { + moduleRoot: ClassDenotation)(cctx0: CondensedContext) { + + implicit val cctx: CondensedContext = cctx0.fresh.withCheckPrefix(false) import ClassfileConstants._ import cctx.base.{settings, loaders, definitions => defn} @@ -32,9 +34,11 @@ class ClassfileParser( protected var currentClassName: Name = _ // JVM name of the current class protected var classTParams = Map[Name,Symbol]() - protected var srcfile0 : Option[AbstractFile] = None //needs fleshing out; this is presumably for the source file attribute, but it is neither set nor used anywhere. - def srcfile = srcfile0 + classRoot.info = new LazyClassInfo { + val decls = instanceScope + def complete(denot: SymDenotation) = unsupported("complete") + } private def currentIsTopLevel = classRoot.owner is Flags.PackageClass @@ -336,9 +340,11 @@ class ClassfileParser( val start = index while (sig(index) != '>') { val tpname = subName(':'.==).toTypeName + val expname = if (owner.isClass) tpname.expandedName(owner) else tpname val s = cctx.newSymbol( - owner, tpname, Flags.TypeParamCreationFlags, + owner, expname, Flags.TypeParamCreationFlags, typeParamCompleter(index), coord = indexCoord(index)) + if (owner.isClass) owner.asClass.enter(s, owner.preCompleteDecls) tparams = tparams + (tpname -> s) sig2typeBounds(tparams, skiptvs = true) newTParams += s diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index e9ae3573e..e34209aa1 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -454,6 +454,9 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: completeRoot( moduleClassRoot, new ModuleClassRootUnpickler(start, moduleClassRoot.symbol, moduleClassRoot.sourceModule.asTerm)) + else if (name == tpnme.REFINE_CLASS) + // create a type alias instead + cctx.newSymbol(owner, name, flags, localMemberUnpickler, coord = start) else cctx.newClassSymbol(owner, name.asTypeName, flags, new LocalClassUnpickler(_), coord = start) case MODULEsym | VALsym => |