Permalink
Browse files

Merge pull request #1892 from retronym/ticket/6479

SI-6479 Don't lift try exprs in label arguments.
  • Loading branch information...
2 parents 621f7a5 + 9cc61f3 commit 6f3ea77870ab5e17805ef0fc338c251e87870b8c @paulp paulp committed Jan 15, 2013
Showing with 60 additions and 2 deletions.
  1. +4 −2 src/compiler/scala/tools/nsc/transform/UnCurry.scala
  2. +56 −0 test/files/pos/t6479.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) }
View
@@ -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()
+ }
+ }
+ }
+
+}

0 comments on commit 6f3ea77

Please sign in to comment.