From 8434922d6f0ead95a2109a5e41f4db4136449e93 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 5 Dec 2012 16:44:53 +0100 Subject: 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. --- test/files/run/t1672.scala | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/files/run/t1672.scala (limited to 'test/files/run/t1672.scala') 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) + } +} -- cgit v1.2.3