diff options
author | Martin Odersky <odersky@gmail.com> | 2013-03-19 15:20:33 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-03-19 15:20:59 +0100 |
commit | 2fdf86e4f9a355eeb2ae7f539824270edd76764a (patch) | |
tree | f3b2a85be493c08cd3b2c00f2943e57b17d3ec7b /src | |
parent | b2f779aad92de0d116cdaf1aba87197695233ebb (diff) | |
download | dotty-2fdf86e4f9a355eeb2ae7f539824270edd76764a.tar.gz dotty-2fdf86e4f9a355eeb2ae7f539824270edd76764a.tar.bz2 dotty-2fdf86e4f9a355eeb2ae7f539824270edd76764a.zip |
Fixing problem with reading typeParams correctly in Unpickler
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 34 |
3 files changed, 30 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index 42711e627..cddf2e990 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -168,6 +168,7 @@ 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) // !!! DEBUG newScopeEntry(sym) sym } diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index bf51b443c..3f37c41f5 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -636,7 +636,8 @@ object SymDenotations { } private def computeTypeParams(implicit ctx: Context): List[TypeSymbol] = - (preCompleteDecls.toList filter (_ is TypeParam)).asInstanceOf[List[TypeSymbol]] + preCompleteDecls.toList.filter(sym => + (sym is TypeParam) && sym.owner == symbol).asInstanceOf[List[TypeSymbol]] // ------ class-specific operations ----------------------------------- diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 00c304196..f7ee0d05c 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -103,7 +103,8 @@ object UnPickler { case cinfo => (Nil, cinfo) } val parentRefs = ctx.normalizeToRefs(parents, cls, decls) - tparams foreach decls.enter + for (tparam <- tparams) + if (!decls.lookup(tparam.name).exists) decls.enter(tparam) denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, optSelfType) } } @@ -163,6 +164,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: case _ => errorBadSignature(s"a runtime exception occured: $ex", Some(ex)) } + private var postReadOp: () => Unit = null + def run() = try { var i = 0 @@ -171,6 +174,10 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: val savedIndex = readIndex readIndex = index(i) entries(i) = readSymbol() + if (postReadOp != null) { + postReadOp() + postReadOp = null + } readIndex = savedIndex } i += 1 @@ -401,11 +408,13 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: } def finishSym(sym: Symbol): Symbol = { - if (sym.owner.isClass && !( - isUnpickleRoot(sym) || - (sym is (ModuleClass | Scala2Existential)) || - isRefinementClass(sym))) - symScope(sym.owner).openForMutations.enter(sym) + if (sym.owner.isClass && + !( isUnpickleRoot(sym) + || (sym is (ModuleClass | Scala2Existential)) + || ((sym is TypeParam) && !sym.owner.isClass) + || isRefinementClass(sym) + ) + ) symScope(sym.owner).openForMutations.enter(sym) sym } @@ -419,6 +428,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: } cctx.newSymbol(owner, name1, flags1, localMemberUnpickler, coord = start) case CLASSsym => + val infoRef = readNat() + postReadOp = () => atReadPos(index(infoRef), readTypeParams) // force reading type params early, so they get entered in the right order. if (isClassRoot) completeRoot(classRoot) else if (isModuleClassRoot) completeRoot(moduleClassRoot) else cctx.newClassSymbol(owner, name.asTypeName, flags, new LocalClassUnpickler(_), coord = start) @@ -467,7 +478,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: denot.addAnnotation(Annotation.makeAlias(alias)) } } - println(s"unpicked ${denot.debugString}, info = ${denot.info}") + println(s"unpickled ${denot.debugString}, info = ${denot.info}") } def startCoord(denot: SymDenotation): Coord = denot.symbol.coord def complete(denot: SymDenotation): Unit = try { @@ -624,6 +635,15 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: } } + def readTypeParams(): List[Symbol] = { + val tag = readByte() + val end = readNat() + readIndex + if (tag == POLYtpe) { + val unusedRestperef = readNat() + until(end, readSymbolRef) + } else Nil + } + def noSuchTypeTag(tag: Int, end: Int): Type = errorBadSignature("bad type tag: " + tag) |