From 2937f4ebca48d5614b5e1a2ae0aa3dac298010a8 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 29 Jan 2007 16:06:54 +0000 Subject: Fixed the bugfix for returns inside finally --- test/files/run/exceptions-2.check | 9 +++++++++ test/files/run/exceptions-2.scala | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'test/files') diff --git a/test/files/run/exceptions-2.check b/test/files/run/exceptions-2.check index 0cfb9a6a8c..95728fb058 100644 --- a/test/files/run/exceptions-2.check +++ b/test/files/run/exceptions-2.check @@ -36,3 +36,12 @@ Return inside synchronized body: Synchronized normal execution... inner finally Outer finally +Return inside body and return in finally: +Normal execution... +inner finally +Outer finally +Return inside body and return in finally inside finally: +Normal execution... +inner finally +finally inside finally +Outer finally diff --git a/test/files/run/exceptions-2.scala b/test/files/run/exceptions-2.scala index 7391789937..e9a7eea963 100644 --- a/test/files/run/exceptions-2.scala +++ b/test/files/run/exceptions-2.scala @@ -178,6 +178,41 @@ object Test { } + def returnInBodyAndInFinally: Unit = try { + try { + Console.println("Normal execution..."); + return + Console.println("non reachable code"); + } finally { + Console.println("inner finally"); + return + } + } finally { + Console.println("Outer finally"); + return + } + + def returnInBodyAndInFinally2: Unit = try { + try { + Console.println("Normal execution..."); + return + Console.println("non reachable code"); + } finally { + try { + Console.println("inner finally"); + return + } finally { + Console.println("finally inside finally"); + } + } + } finally { + Console.println("Outer finally"); + return + } + + + + def execute(f: => Unit) = try { f; } catch { @@ -228,5 +263,11 @@ object Test { Console.println("Return inside synchronized body:"); execute(returnInBodySynch); + + Console.println("Return inside body and return in finally:"); + execute(returnInBodyAndInFinally); + + Console.println("Return inside body and return in finally inside finally:"); + execute(returnInBodyAndInFinally2); } } -- cgit v1.2.3