aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/Pickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-03-03 10:57:03 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:14 +0100
commit60220781967de8c7efafe1e1b6ed09ae482a8582 (patch)
tree4c01f6a3f20f48c0080b69422fb3974350cbb86d /src/dotty/tools/dotc/transform/Pickler.scala
parentb0d73807db5e441badd48c189ef2bc35771021e7 (diff)
downloaddotty-60220781967de8c7efafe1e1b6ed09ae482a8582.tar.gz
dotty-60220781967de8c7efafe1e1b6ed09ae482a8582.tar.bz2
dotty-60220781967de8c7efafe1e1b6ed09ae482a8582.zip
Keeping track of unpickling definition order in Pickler.
The Unpickler visits nodes in a certain order and (so far) expects to see definitions before uses. This commit makes sure that the Unpickler generates definitions in an order that matches the pickler's behavior. Every definition should be "pre-registered" before it can be used. This still allows for mutual recursion between symbols because preregistering enters all symbols of a scope in bulk before generating any references to these symbols. It would be nice if this was the end of the story, but unfortunately that's not the case. It turned out that dotc produced references that were not legal according to the implemented model, and that are also not legal in the formal type system. Each of these violations referred to a symbol outside its scope. There were two sources: 1) Pattern-bound variables were retained in the type of a case block and, consequently, the type of the enclosing match. This has been fixed by a previous commit a0f8ec21c9ce5381bea780e7be89286653fc676e. 2) Dependent anonymous functions led to (illegal) dependent closures with references to their parameters leaking out in the environment. This has been mostly fixed by the previous commits, in particular 1c70842036b083652c3eeab83aad0b2490674bfe. But there are still two problems remaining, see: 89c8bd8a1eb9fb3f0f09f25bedb68de1ef2e2ae8. We might fix the two problems. But it's inconceivable to me that scalac could also produce only "hygienic" trees that do not have escaping references. There are too many situations where we know this is not true (existential skolems, for a start). So we choose to flag escaping variables in logs instead of treating them as errors, and to deal with the situation in the Unpickler.
Diffstat (limited to 'src/dotty/tools/dotc/transform/Pickler.scala')
-rw-r--r--src/dotty/tools/dotc/transform/Pickler.scala6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/Pickler.scala b/src/dotty/tools/dotc/transform/Pickler.scala
index fd50df6ba..7bc41321c 100644
--- a/src/dotty/tools/dotc/transform/Pickler.scala
+++ b/src/dotty/tools/dotc/transform/Pickler.scala
@@ -6,7 +6,7 @@ import TreeTransforms._
import Contexts.Context
import Decorators._
import pickling._
-import config.Printers
+import config.Printers.{noPrinter, pickling}
import java.io.PrintStream
import Periods._
@@ -25,7 +25,7 @@ class Pickler extends MiniPhaseTransform { thisTransform =>
override def transformUnit(tree: Tree)(implicit ctx: Context, info: TransformerInfo): Tree = {
if (!ctx.compilationUnit.isJava) {
val pickler = new TastyPickler
- println(i"unpickling in run ${ctx.runId}")
+ pickling.println(i"unpickling in run ${ctx.runId}")
val previous = if (ctx.settings.YtestPickler.value) tree.show else ""
val treePkl = new TreePickler(pickler)
@@ -40,7 +40,7 @@ class Pickler extends MiniPhaseTransform { thisTransform =>
case (row, i) => s"${i}0: ${row.mkString(" ")}"
}
// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
- if (Printers.pickling ne Printers.noPrinter) new TastyPrinter(bytes).printContents()
+ if (pickling ne noPrinter) new TastyPrinter(bytes).printContents()
if (ctx.settings.YtestPickler.value)
unpickle(bytes, previous)(ctx.fresh.setPeriod(Period(ctx.runId + 1, FirstPhaseId)))