aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-03-05 17:11:46 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:15 +0100
commitc6bba9b9b63da5b28fd70409366c191cec5d2acb (patch)
tree16eb8a295d4a26f75c04826c9ddeaa023b3a734f /src
parent4c80f8949c816f944ff20f9fe07b842eb6164554 (diff)
downloaddotty-c6bba9b9b63da5b28fd70409366c191cec5d2acb.tar.gz
dotty-c6bba9b9b63da5b28fd70409366c191cec5d2acb.tar.bz2
dotty-c6bba9b9b63da5b28fd70409366c191cec5d2acb.zip
More fixes to unpickling
- treated nested Matches correctly - treat nested packages correctly - SELECT always needs to select with sig
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/config/Printers.scala2
-rw-r--r--src/dotty/tools/dotc/core/Decorators.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala43
3 files changed, 25 insertions, 22 deletions
diff --git a/src/dotty/tools/dotc/config/Printers.scala b/src/dotty/tools/dotc/config/Printers.scala
index d1738ee6f..5f112aebc 100644
--- a/src/dotty/tools/dotc/config/Printers.scala
+++ b/src/dotty/tools/dotc/config/Printers.scala
@@ -30,5 +30,5 @@ object Printers {
val config = noPrinter
val transforms = noPrinter
val cyclicErrors = noPrinter
- val pickling = noPrinter
+ val pickling = new Printer
} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala
index 882729063..1ce834428 100644
--- a/src/dotty/tools/dotc/core/Decorators.scala
+++ b/src/dotty/tools/dotc/core/Decorators.scala
@@ -176,7 +176,7 @@ object Decorators {
case _ => arg
}
catch {
- case ex: Exception => s"(missing due to $ex)"
+ case ex: Exception => throw ex // s"(missing due to $ex)"
}
val prefix :: suffixes = sc.parts.toList
diff --git a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
index f9bd85e45..8d7a5e149 100644
--- a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
@@ -614,7 +614,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[
readTerm()(localCtx)
}
readNameSplitSig match {
- case name: Name => readQual(name).select(name)
+ case name: Name => readQual(name).selectWithSig(name, Signature.NotAMethod)
case (name: Name, sig: Signature) => readQual(name).selectWithSig(name, sig)
}
case NEW =>
@@ -667,13 +667,13 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[
val tpt = readTpt()
Closure(until(end)(readTerm()), meth, tpt)
case MATCH =>
- Match(readTerm(), readCases())
+ Match(readTerm(), readCases(end))
case RETURN =>
val from = readSymRef()
val expr = ifBefore(end)(readTerm(), EmptyTree)
Return(expr, Ident(from.termRef))
case TRY =>
- Try(readTerm(), readCases(), ifBefore(end)(readTerm(), EmptyTree))
+ Try(readTerm(), readCases(end), ifBefore(end)(readTerm(), EmptyTree))
case THROW =>
Throw(readTerm())
case REPEATED =>
@@ -714,30 +714,33 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[
if (tp.exists) setPos(start, TypeTree(tp)) else EmptyTree
}
- def readCases()(implicit ctx: Context): List[CaseDef] =
- collectWhile(nextByte == CASEDEF) {
+ def readCases(end: Addr)(implicit ctx: Context): List[CaseDef] =
+ collectWhile(nextByte == CASEDEF && currentAddr != end) { readCase()(ctx.fresh.setNewScope) }
+
+ def readCase()(implicit ctx: Context): CaseDef = {
+ val start = currentAddr
+ readByte()
+ val end = readEnd()
+ val pat = readTerm()
+ val rhs = readTerm()
+ val guard = ifBefore(end)(readTerm(), EmptyTree)
+ setPos(start, CaseDef(pat, guard, rhs))
+ }
+
+ def readTopLevelStat()(implicit ctx: Context): Tree =
+ if (nextByte == PACKAGE) {
val start = currentAddr
readByte()
val end = readEnd()
- val pat = readTerm()
- val rhs = readTerm()
- val guard = ifBefore(end)(readTerm(), EmptyTree)
- setPos(start, CaseDef(pat, guard, rhs))
+ val pid = ref(readTermRef()).asInstanceOf[RefTree]
+ setPos(start,
+ PackageDef(pid, readTopLevelStats()(localContext(pid.symbol.moduleClass))))
}
+ else readIndexedStat(ctx.owner)
def readTopLevelStats()(implicit ctx: Context): List[Tree] = {
fork.indexStats(endAddr)
- until(endAddr) {
- if (nextByte == PACKAGE) {
- val start = currentAddr
- readByte()
- val end = readEnd()
- val pid = ref(readTermRef()).asInstanceOf[RefTree]
- setPos(start,
- PackageDef(pid, readStats(NoSymbol, end)(localContext(pid.symbol.moduleClass))))
- }
- else readIndexedStat(ctx.owner)
- }
+ until(endAddr)(readTopLevelStat)
}
def readLater[T <: AnyRef](end: Addr, op: TreeReader => Context => T): Trees.Lazy[T] = {