diff options
-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 838ea7d5a0..55230f9685 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 |