aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-26 14:26:15 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:11 +0100
commit21f042ecaf136ce544ec899f42e70e2e1a1addf8 (patch)
tree06b2c1a65832abf5ef4e5a6773fd4e44df56eaa2 /src/dotty/tools/dotc/transform
parent76bf36dd64c05fbbf6fd804983379c8c31f52c9d (diff)
downloaddotty-21f042ecaf136ce544ec899f42e70e2e1a1addf8.tar.gz
dotty-21f042ecaf136ce544ec899f42e70e2e1a1addf8.tar.bz2
dotty-21f042ecaf136ce544ec899f42e70e2e1a1addf8.zip
Avoid capturing context in lazy trees
Lazy trees can live longer than runs, so it is important that they capture as little as possible. In particular they should not capture contexts. This change led with a ripple through effect to many changes where operations now have to parameterzied with contexts, in particular in what concerns tree folding. The changes in turn uncovered some areas where dotc was incompatible with scalac, and flagged correct things as errors. These will be fixed in the next commits. Another small twist: EmptyTrees will not be read in delayed mode, so that one can check for lacking definitions without deserializing the rhs.
Diffstat (limited to 'src/dotty/tools/dotc/transform')
-rw-r--r--src/dotty/tools/dotc/transform/CapturedVars.scala2
-rw-r--r--src/dotty/tools/dotc/transform/Constructors.scala2
-rw-r--r--src/dotty/tools/dotc/transform/LambdaLift.scala4
-rw-r--r--src/dotty/tools/dotc/transform/Pickler.scala2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/transform/CapturedVars.scala b/src/dotty/tools/dotc/transform/CapturedVars.scala
index 68bda9782..77b912f08 100644
--- a/src/dotty/tools/dotc/transform/CapturedVars.scala
+++ b/src/dotty/tools/dotc/transform/CapturedVars.scala
@@ -29,7 +29,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisTransfo
private class CollectCaptured(implicit ctx: Context) extends EnclosingMethodTraverser {
private val captured = mutable.HashSet[Symbol]()
- def traverse(enclMeth: Symbol, tree: Tree) = tree match {
+ def traverse(enclMeth: Symbol, tree: Tree)(implicit ctx: Context) = tree match {
case id: Ident =>
val sym = id.symbol
if (sym.is(Mutable, butNot = Method) && sym.owner.isTerm && sym.enclosingMethod != enclMeth) {
diff --git a/src/dotty/tools/dotc/transform/Constructors.scala b/src/dotty/tools/dotc/transform/Constructors.scala
index f61ee68b9..165210cfb 100644
--- a/src/dotty/tools/dotc/transform/Constructors.scala
+++ b/src/dotty/tools/dotc/transform/Constructors.scala
@@ -114,7 +114,7 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
private val seen = mutable.Set[Symbol](accessors: _*)
val retained = mutable.Set[Symbol]()
def dropped: collection.Set[Symbol] = seen -- retained
- override def traverse(tree: Tree) = {
+ override def traverse(tree: Tree)(implicit ctx: Context) = {
val sym = tree.symbol
tree match {
case Ident(_) | Select(This(_), _) if inConstr && seen(tree.symbol) =>
diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala
index 1363615a5..a42e0cc35 100644
--- a/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -161,8 +161,8 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
if (callee.enclosingClass != caller.enclosingClass) calledFromInner += callee
}
- private class CollectDependencies(implicit ctx: Context) extends EnclosingMethodTraverser {
- def traverse(enclMeth: Symbol, tree: Tree) = try { //debug
+ private class CollectDependencies extends EnclosingMethodTraverser {
+ def traverse(enclMeth: Symbol, tree: Tree)(implicit ctx: Context) = try { //debug
val enclosure = enclMeth.skipConstructor
val sym = tree.symbol
def narrowTo(thisClass: ClassSymbol) = {
diff --git a/src/dotty/tools/dotc/transform/Pickler.scala b/src/dotty/tools/dotc/transform/Pickler.scala
index 7a13e1ed6..91d0fac34 100644
--- a/src/dotty/tools/dotc/transform/Pickler.scala
+++ b/src/dotty/tools/dotc/transform/Pickler.scala
@@ -31,7 +31,7 @@ class Pickler extends MiniPhaseTransform { thisTransform =>
// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
if (Printers.pickling ne Printers.noPrinter) new TastyPrinter(bytes).printContents()
- println(i"unpickled:\n ${new DottyUnpickler(bytes, readPositions = false).result}%\n%")
+ //println(i"unpickled:\n ${new DottyUnpickler(bytes, readPositions = false).result}%\n%")
}
tree