aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/UnPickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-03-19 15:20:33 +0100
committerMartin Odersky <odersky@gmail.com>2013-03-19 15:20:59 +0100
commit2fdf86e4f9a355eeb2ae7f539824270edd76764a (patch)
treef3b2a85be493c08cd3b2c00f2943e57b17d3ec7b /src/dotty/tools/dotc/core/pickling/UnPickler.scala
parentb2f779aad92de0d116cdaf1aba87197695233ebb (diff)
downloaddotty-2fdf86e4f9a355eeb2ae7f539824270edd76764a.tar.gz
dotty-2fdf86e4f9a355eeb2ae7f539824270edd76764a.tar.bz2
dotty-2fdf86e4f9a355eeb2ae7f539824270edd76764a.zip
Fixing problem with reading typeParams correctly in Unpickler
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/UnPickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala34
1 files changed, 27 insertions, 7 deletions
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)