summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-23 00:36:18 -0800
committerPaul Phillips <paulp@improving.org>2012-02-23 02:27:05 -0800
commitd5006b118f6ad1bf10ed35491cd0bda05fc88972 (patch)
treed76b018d1de05407467af068e68d8b74d73fe977 /src/compiler/scala/tools/nsc/transform/LambdaLift.scala
parent4a984f82d5bfca05123c53bd385d0299818f8a75 (diff)
downloadscala-d5006b118f6ad1bf10ed35491cd0bda05fc88972.tar.gz
scala-d5006b118f6ad1bf10ed35491cd0bda05fc88972.tar.bz2
scala-d5006b118f6ad1bf10ed35491cd0bda05fc88972.zip
Methods to derive ValDefs and Templates.
It's a lot like the last one. I also found trees being duplicated before being sent to the tree copier. Looks like xerox has gotten a mole in here. Trust no one.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/LambdaLift.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index 99cc7393aa..50a75f896b 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -326,7 +326,7 @@ abstract class LambdaLift extends InfoTransform {
lifted(MethodType(sym.info.params ::: addParams, sym.info.resultType)))
copyDefDef(tree)(vparamss = List(vparams ++ freeParams))
- case ClassDef(mods, name, tparams, impl @ Template(parents, self, body)) =>
+ case ClassDef(mods, name, tparams, impl) =>
// Disabled attempt to to add getters to freeParams
// this does not work yet. Problem is that local symbols need local names
// and references to local symbols need to be transformed into
@@ -338,8 +338,7 @@ abstract class LambdaLift extends InfoTransform {
// DefDef(getter, rhs) setPos tree.pos setType NoType
// }
// val newDefs = if (sym.isTrait) freeParams ::: (ps map paramGetter) else freeParams
- treeCopy.ClassDef(tree, mods, name, tparams,
- treeCopy.Template(impl, parents, self, body ::: freeParams))
+ treeCopy.ClassDef(tree, mods, name, tparams, deriveTemplate(impl)(_ ::: freeParams))
}
case None =>
tree
@@ -481,15 +480,14 @@ abstract class LambdaLift extends InfoTransform {
/** Transform statements and add lifted definitions to them. */
override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
def addLifted(stat: Tree): Tree = stat match {
- case ClassDef(mods, name, tparams, impl @ Template(parents, self, body)) =>
+ case ClassDef(mods, name, tparams, impl) =>
val lifted = liftedDefs get stat.symbol match {
case Some(xs) => xs reverseMap addLifted
case _ => log("unexpectedly no lifted defs for " + stat.symbol) ; Nil
}
- val result = treeCopy.ClassDef(
- stat, mods, name, tparams, treeCopy.Template(impl, parents, self, body ::: lifted))
- liftedDefs -= stat.symbol
- result
+ try treeCopy.ClassDef(stat, mods, name, tparams, deriveTemplate(impl)(_ ::: lifted))
+ finally liftedDefs -= stat.symbol
+
case DefDef(_, _, _, _, _, Block(Nil, expr)) if !stat.symbol.isConstructor =>
deriveDefDef(stat)(_ => expr)
case _ =>