diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-15 12:08:42 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-15 12:08:42 -0800 |
commit | 6f3ea77870ab5e17805ef0fc338c251e87870b8c (patch) | |
tree | dee9b5a1cd15f1f6d346b36551f9dff47a6e0c68 | |
parent | 621f7a56c21686ebbd39b8ffe9282f917fe1f128 (diff) | |
parent | 9cc61f310ef5f80e598956bee20156b7bc472e84 (diff) | |
download | scala-6f3ea77870ab5e17805ef0fc338c251e87870b8c.tar.gz scala-6f3ea77870ab5e17805ef0fc338c251e87870b8c.tar.bz2 scala-6f3ea77870ab5e17805ef0fc338c251e87870b8c.zip |
Merge pull request #1892 from retronym/ticket/6479
SI-6479 Don't lift try exprs in label arguments.
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t6479.scala | 56 |
2 files changed, 60 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index ff08fe4ffa..9908bd689e 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -621,11 +621,13 @@ abstract class UnCurry extends InfoTransform case Apply(fn, args) => if (fn.symbol == Object_synchronized && shouldBeLiftedAnyway(args.head)) transform(treeCopy.Apply(tree, fn, List(liftTree(args.head)))) - else - withNeedLift(true) { + else { + val needLift = needTryLift || !fn.symbol.isLabel // SI-6749, no need to lift in args to label jumps. + withNeedLift(needLift) { val formals = fn.tpe.paramTypes treeCopy.Apply(tree, transform(fn), transformTrees(transformArgs(tree.pos, fn.symbol, args, formals))) } + } case Assign(Select(_, _), _) => withNeedLift(true) { super.transform(tree) } diff --git a/test/files/pos/t6479.scala b/test/files/pos/t6479.scala new file mode 100644 index 0000000000..c463bc5ab0 --- /dev/null +++ b/test/files/pos/t6479.scala @@ -0,0 +1,56 @@ +object TailrecAfterTryCatch { + + @annotation.tailrec + final def good1() { + 1 match { + case 2 => { + try { + // return + } catch { + case e: ClassNotFoundException => + } + good1() + } + } + } + + @annotation.tailrec + final def good2() { + //1 match { + // case 2 => { + try { + return + } catch { + case e: ClassNotFoundException => + } + good2() + // } + //} + } + + @annotation.tailrec + final def good3() { + val 1 = 2 + try { + return + } catch { + case e: ClassNotFoundException => + } + good3() + } + + @annotation.tailrec + final def bad() { + 1 match { + case 2 => { + try { + return + } catch { + case e: ClassNotFoundException => + } + bad() + } + } + } + +}
\ No newline at end of file |