diff options
author | odersky <odersky@gmail.com> | 2015-08-09 15:16:06 -0700 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2015-08-09 15:16:06 -0700 |
commit | 9eb55f1bb112030fe783e42c129e02f91c0aaef5 (patch) | |
tree | cd4e85edd99b7dfe8fd691c2eb711140d761bebc /tests/run/liftedTry.scala | |
parent | 07e24e8640acf19a6bcedd1b68acbd7c8d8bf29b (diff) | |
parent | 694aabd5caa2a67721f82db4027d28815af90275 (diff) | |
download | dotty-9eb55f1bb112030fe783e42c129e02f91c0aaef5.tar.gz dotty-9eb55f1bb112030fe783e42c129e02f91c0aaef5.tar.bz2 dotty-9eb55f1bb112030fe783e42c129e02f91c0aaef5.zip |
Merge pull request #748 from dotty-staging/add/non-local/returns
Implement non-local returns
Diffstat (limited to 'tests/run/liftedTry.scala')
-rw-r--r-- | tests/run/liftedTry.scala | 21 |
1 files changed, 21 insertions, 0 deletions
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) + } +} + |