diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-03-22 10:39:29 +0100 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-03-23 18:27:57 +0100 |
commit | d4a58883c470214a8aded30cfa8274f26083f8c6 (patch) | |
tree | 06c68ba36971b81799094856c6d22eb3cce6abfb /src/compiler | |
parent | bc44da79df7810f65bc14e19167a85796e675b45 (diff) | |
download | scala-d4a58883c470214a8aded30cfa8274f26083f8c6.tar.gz scala-d4a58883c470214a8aded30cfa8274f26083f8c6.tar.bz2 scala-d4a58883c470214a8aded30cfa8274f26083f8c6.zip |
[vpm] avoid verifyerror: leave jump to tail-pos label
the following commit deals with the fall-out in basicblocks
(double closing of blocks in ignore mode)
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/TailCalls.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index ef76fe1b1c..9915f7e9fc 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -341,13 +341,18 @@ abstract class TailCalls extends Transform { else if (fun.symbol.isLabel && args.nonEmpty && args.tail.isEmpty && ctx.tailLabels(fun.symbol)) { // 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} - // thus, the argument to the call is in tailposition and we don't need to jump to the label, tail jump instead + // thus, the argument to the call is in tailposition val saved = ctx.tailPos ctx.tailPos = true debuglog("in tailpos label: "+ args.head) val res = transform(args.head) ctx.tailPos = saved - if (res ne args.head) res // we tail-called -- TODO: shield from false-positives where we rewrite but don't tail-call + if (res ne args.head) { + // we tail-called -- TODO: shield from false-positives where we rewrite but don't tail-call + // must leave the jump to the original tailpos-label (fun)! + // there might be *a* tailcall *in* res, but it doesn't mean res *always* tailcalls + treeCopy.Apply(tree, fun, List(res)) + } else rewriteApply(fun, fun, Nil, args) } else rewriteApply(fun, fun, Nil, args) |