summaryrefslogtreecommitdiff
path: root/test/files/run/t1672.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-12-05 16:44:53 +0100
committerJason Zaugg <jzaugg@gmail.com>2012-12-05 16:44:53 +0100
commit8434922d6f0ead95a2109a5e41f4db4136449e93 (patch)
tree890af18c98fe91e6d37db66654ac5642cd424182 /test/files/run/t1672.scala
parent31a0aa75cf9739b2ae565d634670f6c0ce89bbc1 (diff)
downloadscala-8434922d6f0ead95a2109a5e41f4db4136449e93.tar.gz
scala-8434922d6f0ead95a2109a5e41f4db4136449e93.tar.bz2
scala-8434922d6f0ead95a2109a5e41f4db4136449e93.zip
Addtional test cases for tail calls in catches.
- Includes a run test to check bytecode verifies and behaves - Show this isn't possible when try is used as an expression, and a `liftedTree` local method is needed.
Diffstat (limited to 'test/files/run/t1672.scala')
-rw-r--r--test/files/run/t1672.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/files/run/t1672.scala b/test/files/run/t1672.scala
new file mode 100644
index 0000000000..ee025b9031
--- /dev/null
+++ b/test/files/run/t1672.scala
@@ -0,0 +1,28 @@
+object Test {
+ @annotation.tailrec
+ def bar(i : Int) : Int = {
+ if (i == 0) 0
+ else try {
+ throw new RuntimeException
+ } catch {
+ case _: Throwable => bar(i - 1)
+ }
+ }
+
+ @annotation.tailrec
+ def nestedTry1(i : Int) : Int = {
+ if (i == 0) 0
+ else try {
+ throw new RuntimeException
+ } catch {
+ case _: Throwable =>
+ try { ??? } catch { case _: Throwable => nestedTry1(i - 1) }
+ }
+ }
+
+ def main(args: Array[String]) {
+ assert(bar(2) == 0)
+
+ assert(nestedTry1(2) == 0)
+ }
+}