summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2009-05-30 07:36:31 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2009-05-30 07:36:31 +0000
commit390ccacfe0caa4c07af6193dec3e172c0fcd7896 (patch)
tree001ff4a00bd9d8cab651d9bf245bfc795748d829 /src/compiler/scala/tools/nsc/transform/LambdaLift.scala
parent661f1ba10e5062fd987c4cafe43ad1f0dc3f5491 (diff)
downloadscala-390ccacfe0caa4c07af6193dec3e172c0fcd7896.tar.gz
scala-390ccacfe0caa4c07af6193dec3e172c0fcd7896.tar.bz2
scala-390ccacfe0caa4c07af6193dec3e172c0fcd7896.zip
Named and default arguments
- MethodTypes now have (params: List[Symbol]) - "copy"-methods for case classes - the "copy" object in the compiler is now called "treeCopy"
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/LambdaLift.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index 2c2314f880..41b2cc53a7 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -101,9 +101,8 @@ abstract class LambdaLift extends InfoTransform {
def localToConstr(sym: Symbol) =
if (sym.isLocalDummy) sym.owner.primaryConstructor else sym;
var encl = localToConstr(sym)
- while (!encl.isMethod && !encl.isClass) {
- encl = localToConstr(outer(encl));
- }
+ while (!encl.isMethod && !encl.isClass)
+ encl = localToConstr(outer(encl))
encl
}
@@ -318,12 +317,13 @@ abstract class LambdaLift extends InfoTransform {
val freeParams = ps map (p => ValDef(p) setPos tree.pos setType NoType);
tree match {
case DefDef(mods, name, tparams, List(vparams), tpt, rhs) =>
+ val addParams = cloneSymbols(ps).map(_.setFlag(PARAM))
sym.updateInfo(
- lifted(MethodType(sym.info.paramTypes ::: (ps map (_.tpe)), sym.info.resultType)));
- copy.DefDef(tree, mods, name, tparams, List(vparams ::: freeParams), tpt, rhs)
+ lifted(MethodType(sym.info.params ::: addParams, sym.info.resultType)))
+ treeCopy.DefDef(tree, mods, name, tparams, List(vparams ::: freeParams), tpt, rhs)
case ClassDef(mods, name, tparams, impl @ Template(parents, self, body)) =>
- copy.ClassDef(tree, mods, name, tparams,
- copy.Template(impl, parents, self, body ::: freeParams))
+ treeCopy.ClassDef(tree, mods, name, tparams,
+ treeCopy.Template(impl, parents, self, body ::: freeParams))
}
case None =>
tree
@@ -358,20 +358,20 @@ abstract class LambdaLift extends InfoTransform {
Apply(Select(New(TypeTree(sym.tpe)), nme.CONSTRUCTOR), List(rhs))
}
}
- copy.ValDef(tree, mods, name, tpt1, rhs1)
+ treeCopy.ValDef(tree, mods, name, tpt1, rhs1)
} else tree
case Return(Block(stats, value)) =>
- Block(stats, copy.Return(tree, value)) setType tree.tpe setPos tree.pos
+ Block(stats, treeCopy.Return(tree, value)) setType tree.tpe setPos tree.pos
case Return(expr) =>
assert(sym == currentMethod, sym)
tree
case Apply(fn, args) =>
- copy.Apply(tree, fn, addFreeArgs(tree.pos, sym, args))
+ treeCopy.Apply(tree, fn, addFreeArgs(tree.pos, sym, args))
case Assign(Apply(TypeApply(sel @ Select(qual, _), _), List()), rhs) =>
// eliminate casts introduced by selecting a captured variable field
// on the lhs of an assignment.
assert(sel.symbol == Object_asInstanceOf)
- copy.Assign(tree, qual, rhs)
+ treeCopy.Assign(tree, qual, rhs)
case Ident(name) =>
val tree1 =
if (sym != NoSymbol && sym.isTerm && !sym.isLabel)
@@ -401,13 +401,13 @@ abstract class LambdaLift extends InfoTransform {
def addLifted(stat: Tree): Tree = stat match {
case ClassDef(mods, name, tparams, impl @ Template(parents, self, body)) =>
val lifted = liftedDefs(stat.symbol).toList map addLifted
- val result = copy.ClassDef(
- stat, mods, name, tparams, copy.Template(impl, parents, self, body ::: lifted))
+ val result = treeCopy.ClassDef(
+ stat, mods, name, tparams, treeCopy.Template(impl, parents, self, body ::: lifted))
liftedDefs -= stat.symbol
result
case DefDef(mods, name, tp, vp, tpt, Block(Nil, expr))
if !stat.symbol.isConstructor =>
- copy.DefDef(stat, mods, name, tp, vp, tpt, expr)
+ treeCopy.DefDef(stat, mods, name, tp, vp, tpt, expr)
case _ =>
stat
}