diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2009-05-30 07:36:31 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2009-05-30 07:36:31 +0000 |
commit | 390ccacfe0caa4c07af6193dec3e172c0fcd7896 (patch) | |
tree | 001ff4a00bd9d8cab651d9bf245bfc795748d829 /src/compiler/scala/tools/nsc/transform/TailCalls.scala | |
parent | 661f1ba10e5062fd987c4cafe43ad1f0dc3f5491 (diff) | |
download | scala-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/TailCalls.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/TailCalls.scala | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 3df490caac..af6c65ece2 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -157,7 +157,8 @@ abstract class TailCalls extends Transform val newCtx = mkContext(ctx) newCtx.currentMethod = tree.symbol newCtx.makeLabel() - newCtx.label.setInfo(MethodType(currentClass.tpe :: tree.symbol.tpe.paramTypes, tree.symbol.tpe.finalResultType)) + val currentClassParam = tree.symbol.newSyntheticValueParam(currentClass.tpe) + newCtx.label.setInfo(MethodType(currentClassParam :: tree.symbol.tpe.params, tree.symbol.tpe.finalResultType)) newCtx.tailPos = true val t1 = if (newCtx.currentMethod.isFinal || @@ -187,11 +188,11 @@ abstract class TailCalls extends Transform LabelDef(newCtx.label, newThis :: (List.flatten(vparams) map (_.symbol)), newRHS)))); - copy.DefDef(tree, mods, name, tparams, vparams, tpt, newRHS); + treeCopy.DefDef(tree, mods, name, tparams, vparams, tpt, newRHS); } else - copy.DefDef(tree, mods, name, tparams, vparams, tpt, newRHS); + treeCopy.DefDef(tree, mods, name, tparams, vparams, tpt, newRHS); } else { - copy.DefDef(tree, mods, name, tparams, vparams, tpt, transform(rhs, newCtx)) + treeCopy.DefDef(tree, mods, name, tparams, vparams, tpt, transform(rhs, newCtx)) } if (!isTransformed && tailrecRequired(dd)) @@ -218,12 +219,12 @@ abstract class TailCalls extends Transform super.transform(tree) case Block(stats, expr) => - copy.Block(tree, - transformTrees(stats, mkContext(ctx, false)), - transform(expr)) + treeCopy.Block(tree, + transformTrees(stats, mkContext(ctx, false)), + transform(expr)) case CaseDef(pat, guard, body) => - copy.CaseDef(tree, pat, guard, transform(body)) + treeCopy.CaseDef(tree, pat, guard, transform(body)) case Sequence(_) | Alternative(_) | Star(_) | Bind(_, _) => @@ -237,24 +238,24 @@ abstract class TailCalls extends Transform super.transform(tree) case If(cond, thenp, elsep) => - copy.If(tree, cond, transform(thenp), transform(elsep)) + treeCopy.If(tree, cond, transform(thenp), transform(elsep)) case Match(selector, cases) => //super.transform(tree); - copy.Match(tree, transform(selector, mkContext(ctx, false)), transformTrees(cases).asInstanceOf[List[CaseDef]]) + treeCopy.Match(tree, transform(selector, mkContext(ctx, false)), transformTrees(cases).asInstanceOf[List[CaseDef]]) case Return(expr) => super.transform(tree) case Try(block, catches, finalizer) => // no calls inside a try are in tail position, but keep recursing for nested functions - copy.Try(tree, transform(block, mkContext(ctx, false)), - transformTrees(catches, mkContext(ctx, false)).asInstanceOf[List[CaseDef]], - transform(finalizer, mkContext(ctx, false))) + treeCopy.Try(tree, transform(block, mkContext(ctx, false)), + transformTrees(catches, mkContext(ctx, false)).asInstanceOf[List[CaseDef]], + transform(finalizer, mkContext(ctx, false))) case Throw(expr) => super.transform(tree) case New(tpt) => super.transform(tree) case Typed(expr, tpt) => super.transform(tree) case Apply(tapply @ TypeApply(fun, targs), vargs) => - lazy val defaultTree = copy.Apply(tree, tapply, transformTrees(vargs, mkContext(ctx, false))) + lazy val defaultTree = treeCopy.Apply(tree, tapply, transformTrees(vargs, mkContext(ctx, false))) if ( ctx.currentMethod.isFinal && ctx.tailPos && isSameTypes(ctx.tparams, targs map (_.tpe.typeSymbol)) && @@ -280,10 +281,10 @@ abstract class TailCalls extends Transform case Apply(fun, args) if (fun.symbol == definitions.Boolean_or || fun.symbol == definitions.Boolean_and) => - copy.Apply(tree, fun, transformTrees(args)) + treeCopy.Apply(tree, fun, transformTrees(args)) case Apply(fun, args) => - lazy val defaultTree = copy.Apply(tree, fun, transformTrees(args, mkContext(ctx, false))) + lazy val defaultTree = treeCopy.Apply(tree, fun, transformTrees(args, mkContext(ctx, false))) if (ctx.currentMethod.isFinal && ctx.tailPos && isRecursiveCall(fun)) { |