diff options
author | Martin Odersky <odersky@gmail.com> | 2015-08-05 12:35:34 -0700 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-08-05 13:31:58 -0700 |
commit | 3f46a7506454f01f1b3d79b60d1b48845bde8d4a (patch) | |
tree | 9bb820d191a57ec1a7aca9ff9ab50638ac217d61 /tests/run | |
parent | 2a306ddcfe78589310d462bbf67fb893ce8702aa (diff) | |
download | dotty-3f46a7506454f01f1b3d79b60d1b48845bde8d4a.tar.gz dotty-3f46a7506454f01f1b3d79b60d1b48845bde8d4a.tar.bz2 dotty-3f46a7506454f01f1b3d79b60d1b48845bde8d4a.zip |
Add LiftTry phase
Phase lifts tries that would be illegal because they execute on non-empty
expression stacks.
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/StackMap.scala | 7 | ||||
-rw-r--r-- | tests/run/liftedTry.scala | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/run/StackMap.scala b/tests/run/StackMap.scala new file mode 100644 index 000000000..5220758fe --- /dev/null +++ b/tests/run/StackMap.scala @@ -0,0 +1,7 @@ +object Test { + var implicitsCache = null + + def main(args: Array[String]): Unit = { + implicitsCache = try{null} catch { case ex: Exception => null } + } +} diff --git a/tests/run/liftedTry.scala b/tests/run/liftedTry.scala new file mode 100644 index 000000000..2e4c25c2b --- /dev/null +++ b/tests/run/liftedTry.scala @@ -0,0 +1,21 @@ +object Test { + + def raise(x: Int) = { throw new Exception(s"$x"); 0 } + def handle: Throwable => Int = { case ex: Exception => ex.getMessage().toInt } + + val x = try raise(1) catch handle + + def foo(x: Int) = { + val y = try raise(x) catch handle + y + } + + foo(try 3 catch handle) + + def main(args: Array[String]) = { + assert(x == 1) + assert(foo(2) == 2) + assert(foo(try raise(3) catch handle) == 3) + } +} + |