diff options
author | Martin Odersky <odersky@gmail.com> | 2013-03-24 00:26:30 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-03-24 00:26:30 +0100 |
commit | b791ef8e586d86af68f1212c9abecc22bb2d4de1 (patch) | |
tree | 2d66deb239c59a392129e42ba112532863ffbdaa /src/dotty/tools | |
parent | 8ea3a4627c7dc66f65705ec9822c01a2225eacae (diff) | |
download | dotty-b791ef8e586d86af68f1212c9abecc22bb2d4de1.tar.gz dotty-b791ef8e586d86af68f1212c9abecc22bb2d4de1.tar.bz2 dotty-b791ef8e586d86af68f1212c9abecc22bb2d4de1.zip |
Fixes fingerprint problems.
Also reducing debug output. Can now read and display all classes and objects in scala.collection.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Flags.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymbolLoaders.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 26 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 3 |
9 files changed, 26 insertions, 33 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 95ad16b54..8ac67dd02 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -66,7 +66,7 @@ class Definitions(implicit ctx: Context) { lazy val AnyRefAlias: TypeSymbol = { val anyRef = ctx.newSymbol( ScalaPackageClass, tpnme.AnyRef, EmptyFlags, TypeAlias(ObjectClass.typeConstructor)) - ScalaPackageClass.preCompleteDecls.openForMutations.enter(anyRef) // @@@ ScalaPackageClass.enter(anyRef, ScalaPackageClass.preCompleteDecls) + ScalaPackageClass.enter(anyRef, ScalaPackageClass.preCompleteDecls) anyRef } lazy val AnyClass: ClassSymbol = ctx.newCompleteClassSymbol( diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala index 43d5e5cd1..4e7e74862 100644 --- a/src/dotty/tools/dotc/core/Flags.scala +++ b/src/dotty/tools/dotc/core/Flags.scala @@ -328,7 +328,7 @@ object Flags { final val Touched = commonFlag(48, "<touched>") /** Class is not allowed to accept new members because fingerprint of subclass has been taken */ - final val Frozen = typeFlag(49, "<frozen>") + final val Frozen = commonFlag(49, "<frozen>") /** An error symbol */ final val Erroneous = commonFlag(50, "<is-error>") @@ -371,7 +371,7 @@ object Flags { /** Flags guaranteed to be set upon symbol creation */ final val FromStartFlags = AccessFlags | Module | Package | Deferred | Param | Scala2ExistentialCommon | Touched | - Static | CovariantCommon | ContravariantCommon | ExpandedName | AccessorOrSealed + Static | CovariantCommon | ContravariantCommon | ExpandedName | AccessorOrSealed | Frozen assert(FromStartFlags.isTermFlags && FromStartFlags.isTypeFlags) // TODO: Should check that FromStartFlags do not changed in completion diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index f3fde7209..d39194bf1 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -108,9 +108,6 @@ object Scopes { syms } - /** Cast this scope to a mutable scope @@@ */ - final def openForMutations: MutableScope = this.asInstanceOf[MutableScope] - final def toText(implicit ctx: Context): Text = ctx.toText(this) } diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 3a6737403..93de8e4ff 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -98,11 +98,11 @@ object SymDenotations { private def completeFrom(completer: LazyType): Unit = { if (_flags is Touched) throw new CyclicReference(this) _flags |= Touched - Context.theBase.initialCtx.traceIndented( // !!! DEBUG - ">>>> completing "+this.debugString+"/"+owner.id, - "<<<< completed: "+this.debugString) { +// Context.theBase.initialCtx.traceIndented( // !!! DEBUG +// ">>>> completing "+this.debugString+"/"+owner.id, +// "<<<< completed: "+this.debugString) { completer.complete(this) - } +// } } protected[core] final def info_=(tp: Type) = { @@ -740,7 +740,7 @@ object SymDenotations { var fp = FingerPrint() var e = info.decls.lastEntry while (e != null) { - fp.include(name) + fp.include(e.sym.name) e = e.prev } var ps = classInfo.classParents diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala index c2b873bc9..cb20b894a 100644 --- a/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -29,10 +29,7 @@ class SymbolLoaders { owner: Symbol, member: Symbol, completer: SymbolLoader, scope: Scope = EmptyScope)(implicit ctx: Context): Symbol = { assert(scope.lookup(member.name) == NoSymbol, owner.fullName + "." + member.name) - scope match { - case scope: MutableScope => scope.enter(member) - case _ => owner.asClass.enter(member) - } + owner.asClass.enter(member, scope) member } diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index c19b0e387..847fb0ebd 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -165,7 +165,7 @@ trait TypeOps { this: Context => * to a list of typerefs, by converting all refinements to member * definitions in scope `decls`. Can add members to `decls` as a side-effect. */ - def normalizeToRefs(parents: List[Type], cls: ClassSymbol, decls: MutableScope /*@@@*/): List[TypeRef] = { + def normalizeToRefs(parents: List[Type], cls: ClassSymbol, decls: Scope): List[TypeRef] = { // println(s"normalizing $parents of $cls in ${cls.owner}") // !!! DEBUG var refinements = Map[TypeName, Type]() var formals = Map[TypeName, Symbol]() @@ -190,7 +190,7 @@ trait TypeOps { this: Context => assert(decls.lookup(name) == NoSymbol, // DEBUG s"redefinition of ${decls.lookup(name).debugString} in ${cls.showLocated}") val sym = ctx.newSymbol(cls, name, formal.flags & RetainedTypeArgFlags, bounds) - decls.enter(sym) // @@@ cls.enter(sym, decls) + cls.enter(sym, decls) } parentRefs } diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 60dfc9d9b..11dcd2152 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -125,7 +125,7 @@ class ClassfileParser( instanceScope.lookup(nme.CONSTRUCTOR) == NoSymbol && !(sflags is Flags.Interface) if (needsConstructor) - instanceScope enter cctx.newDefaultConstructor(classRoot.symbol.asClass) + classRoot.enter(cctx.newDefaultConstructor(classRoot.symbol.asClass), instanceScope) classInfo = parseAttributes(classRoot.symbol, classInfo) setClassInfo(classRoot, classInfo) diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 982cbd622..f86d7cc26 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -29,7 +29,7 @@ object UnPickler { } /** Temporary type for classinfos, will be decomposed on completion of the class */ - case class TempClassInfoType(parentTypes: List[Type], decls: /*@@@*/MutableScope, clazz: Symbol) extends UncachedGroundType + case class TempClassInfoType(parentTypes: List[Type], decls: Scope, clazz: Symbol) extends UncachedGroundType /** Convert temp poly type to some native Dotty idiom. * @param forSym The symbol that gets the converted type as info. @@ -108,7 +108,7 @@ object UnPickler { for (tparam <- tparams) { val tsym = decls.lookup(tparam.name) if (tsym.exists) tsym.setFlag(TypeParam) - else decls.enter(tparam) // @@@ denot.enter(tparam, decls) + else denot.enter(tparam, decls) } var ost = optSelfType if (ost == NoType && (denot is ModuleClass)) @@ -378,7 +378,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: nestedObjectSymbol orElse { // // (4) Call the mirror's "missing" hook. adjust(cctx.base.missingHook(owner, name)) orElse { - println(owner.info.decls.toList.map(_.debugString).mkString("\n ")) // !!! DEBUG + // println(owner.info.decls.toList.map(_.debugString).mkString("\n ")) // !!! DEBUG // } // (5) Create a stub symbol to defer hard failure a little longer. cctx.newStubSymbol(owner, name, source) @@ -404,9 +404,9 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: def isModuleClassRoot = (name == moduleClassRoot.name) && (owner == moduleClassRoot.owner) && (flags is Module) def isModuleRoot = (name == moduleClassRoot.name.toTermName) && (owner == moduleClassRoot.owner) && (flags is Module) - if (isClassRoot) println(s"classRoot of $classRoot found at $readIndex, flags = $flags") // !!! DEBUG - if (isModuleRoot) println(s"moduleRoot of $moduleRoot found at $readIndex, flags = $flags") // !!! DEBUG - if (isModuleClassRoot) println(s"moduleClassRoot of $moduleClassRoot found at $readIndex, flags = $flags") // !!! DEBUG + //if (isClassRoot) println(s"classRoot of $classRoot found at $readIndex, flags = $flags") // !!! DEBUG + //if (isModuleRoot) println(s"moduleRoot of $moduleRoot found at $readIndex, flags = $flags") // !!! DEBUG + //if (isModuleClassRoot) println(s"moduleClassRoot of $moduleClassRoot found at $readIndex, flags = $flags") // !!! DEBUG def completeRoot(denot: ClassDenotation, completer: LazyType): Symbol = { denot.setFlag(flags) @@ -422,7 +422,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: || ((sym is TypeParam) && !sym.owner.isClass) || isRefinementClass(sym) ) - ) symScope(sym.owner).openForMutations.enter(sym) // @@@ sym.owner.asClass.enter(sym, symScope(sym.owner)) + ) sym.owner.asClass.enter(sym, symScope(sym.owner)) sym } @@ -474,7 +474,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: inforef = readNat() pw } - println("reading type for "+denot) + // println("reading type for "+denot) // !!! DEBUG val tp = at(inforef, () => readType(forceProperType = denot.isTerm)) denot match { case denot: ClassDenotation => @@ -493,7 +493,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: denot.addAnnotation(Annotation.makeAlias(alias)) } } - println(s"unpickled ${denot.debugString}, info = ${denot.info}") + // println(s"unpickled ${denot.debugString}, info = ${denot.info}") !!! DEBUG } def startCoord(denot: SymDenotation): Coord = denot.symbol.coord def complete(denot: SymDenotation): Unit = try { @@ -620,9 +620,9 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: sym.asType) } else TypeRef(pre, sym.name.asTypeName) val args = until(end, readTypeRef) - if (args.nonEmpty) { // DEBUG - println(s"reading app type $tycon $args") - } +// if (args.nonEmpty) { // DEBUG +// println(s"reading app type $tycon $args") +// } tycon.appliedTo(args) case TYPEBOUNDStpe => TypeBounds(readTypeRef(), readTypeRef()) @@ -643,7 +643,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: } case CLASSINFOtpe => val clazz = readSymbolRef() - TempClassInfoType(until(end, readTypeRef), symScope(clazz).openForMutations /*@@@*/, clazz) + TempClassInfoType(until(end, readTypeRef), symScope(clazz), clazz) case METHODtpe | IMPLICITMETHODtpe => val restpe = readTypeRef() val params = until(end, readSymbolRef) diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index dac2b6874..77cbc3662 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -15,8 +15,7 @@ trait Reporting { this: Context => def inform(msg: String, pos: Position = NoPosition): Unit = reporter.info(msg, pos) def log(msg: => String): Unit = - if (true || // !!! for now - this.settings.log.value.containsPhase(phase)) + if (this.settings.log.value.containsPhase(phase)) inform(s"[log ${ctx.phasesStack.reverse.mkString(" -> ")}] $msg") def debuglog(msg: => String): Unit = |