summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala6
-rw-r--r--test/files/pos/t3869.scala10
2 files changed, 15 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 1157b1836d..7bfabc239f 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -691,10 +691,14 @@ abstract class GenICode extends SubComponent {
ctx1.bb.emit(STORE_LOCAL(tmp))
true
}
+
+ // duplicate finalizer (takes care of anchored labels)
+ val f1 = duplicateFinalizer(Set.empty ++ ctx1.labels.keySet, ctx1, f)
+
// we have to run this without the same finalizer in
// the list, otherwise infinite recursion happens for
// finalizers that contain 'return'
- ctx1 = genLoad(f, ctx1.removeFinalizer(f), UNIT)
+ ctx1 = genLoad(f1, ctx1.removeFinalizer(f), UNIT)
saved
}
}
diff --git a/test/files/pos/t3869.scala b/test/files/pos/t3869.scala
new file mode 100644
index 0000000000..acd19abb24
--- /dev/null
+++ b/test/files/pos/t3869.scala
@@ -0,0 +1,10 @@
+
+// see ticket #3869
+object Test {
+ def f: Unit =
+ try return finally while(true) ()
+
+ def main(args: Array[String]) {
+ f
+ }
+}