diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala | 4 | ||||
-rw-r--r-- | test/files/run/exceptions-nest.check | 1 | ||||
-rw-r--r-- | test/files/run/exceptions-nest.scala | 18 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 92ba50e88e..174a1b778e 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -851,6 +851,10 @@ abstract class GenMSIL extends SubComponent { log("Generating code for block: " + block) for (handler <- beginCatchBlock.get(block)) { + if (!currentHandlers.isEmpty && currentHandlers.top.covered == handler.covered) { + currentHandlers.pop() + currentHandlers.push(handler) + } if (handler.cls == NoSymbol) { // `finally` blocks are represented the same as `catch`, but with no catch-type mcode.BeginFinallyBlock() diff --git a/test/files/run/exceptions-nest.check b/test/files/run/exceptions-nest.check index ae66da0a99..48725e4d27 100644 --- a/test/files/run/exceptions-nest.check +++ b/test/files/run/exceptions-nest.check @@ -10,3 +10,4 @@ OK 10 1 () +10 diff --git a/test/files/run/exceptions-nest.scala b/test/files/run/exceptions-nest.scala index 40b00988e4..d3f37452b5 100644 --- a/test/files/run/exceptions-nest.scala +++ b/test/files/run/exceptions-nest.scala @@ -11,6 +11,7 @@ object Test extends Application { println(test9) println(test10) println(test11) + println(test12) def test1 = { var x = 1 @@ -136,4 +137,21 @@ object Test extends Application { try { () } catch { case e => () } } + + class E1 extends Exception + class E2 extends Exception + class E3 extends Exception + + def test12_impl(op: => Int) = try { + op + } catch { + case e: E1 => 2 + case e: E2 => 3 + case e: E3 => 4 + } + def test12 = + test12_impl(1) + + test12_impl(throw new E1) + + test12_impl(throw new E2) + + test12_impl(throw new E3) } |