diff options
author | Johannes Rudolph <johannes.rudolph@gmail.com> | 2014-06-25 13:40:13 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes.rudolph@gmail.com> | 2014-06-25 15:24:26 +0200 |
commit | 299594e63a925c3e6042c6fd920de2f359417cbd (patch) | |
tree | 61558e65344b295d63c0ec425782c607e47d4104 /src | |
parent | 1c0b48da8dfa124eb762620c8cb803a9079b7c81 (diff) | |
download | scala-299594e63a925c3e6042c6fd920de2f359417cbd.tar.gz scala-299594e63a925c3e6042c6fd920de2f359417cbd.tar.bz2 scala-299594e63a925c3e6042c6fd920de2f359417cbd.zip |
SI-8657 don't miss tailrec defs in more positions
1) First operand of boolean expression using `&&` or `||`. Second operands of
those boolean exprs were already treated specially here but handling for first
operands was missing.
2) Condition of `If`. Also added a test for guards.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/TailCalls.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 714f189ead..d9d1192772 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -328,11 +328,14 @@ abstract class TailCalls extends Transform { ) case CaseDef(pat, guard, body) => + // CaseDefs are already translated and guards were moved into the body. + // If this was not the case, guards would have to be transformed here as well. + assert(guard.isEmpty) deriveCaseDef(tree)(transform) case If(cond, thenp, elsep) => treeCopy.If(tree, - cond, + noTailTransform(cond), transform(thenp), transform(elsep) ) @@ -363,7 +366,7 @@ abstract class TailCalls extends Transform { rewriteApply(tapply, fun, targs, vargs) case Apply(fun, args) if fun.symbol == Boolean_or || fun.symbol == Boolean_and => - treeCopy.Apply(tree, fun, transformTrees(args)) + treeCopy.Apply(tree, noTailTransform(fun), transformTrees(args)) // this is to detect tailcalls in translated matches // it's a one-argument call to a label that is in a tailposition and that looks like label(x) {x} |