summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-12-05 14:16:27 +0100
committerJason Zaugg <jzaugg@gmail.com>2012-12-05 14:24:12 +0100
commit31a0aa75cf9739b2ae565d634670f6c0ce89bbc1 (patch)
tree26a0d4b359da879707eed080394a26509f7cbed7 /test/files/neg
parentfd57069a3a49de1757a518b573a0cd8cb98bbbd5 (diff)
downloadscala-31a0aa75cf9739b2ae565d634670f6c0ce89bbc1.tar.gz
scala-31a0aa75cf9739b2ae565d634670f6c0ce89bbc1.tar.bz2
scala-31a0aa75cf9739b2ae565d634670f6c0ce89bbc1.zip
SI-1672 Catches are in tail position without finally.
So we can eliminate tail calls within.
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/t1672b.check13
-rw-r--r--test/files/neg/t1672b.scala41
2 files changed, 54 insertions, 0 deletions
diff --git a/test/files/neg/t1672b.check b/test/files/neg/t1672b.check
new file mode 100644
index 0000000000..288e47c315
--- /dev/null
+++ b/test/files/neg/t1672b.check
@@ -0,0 +1,13 @@
+t1672b.scala:3: error: could not optimize @tailrec annotated method bar: it contains a recursive call not in tail position
+ def bar : Nothing = {
+ ^
+t1672b.scala:14: error: could not optimize @tailrec annotated method baz: it contains a recursive call not in tail position
+ def baz : Nothing = {
+ ^
+t1672b.scala:29: error: could not optimize @tailrec annotated method boz: it contains a recursive call not in tail position
+ case _: Throwable => boz; ???
+ ^
+t1672b.scala:34: error: could not optimize @tailrec annotated method bez: it contains a recursive call not in tail position
+ def bez : Nothing = {
+ ^
+four errors found
diff --git a/test/files/neg/t1672b.scala b/test/files/neg/t1672b.scala
new file mode 100644
index 0000000000..7d02ddc710
--- /dev/null
+++ b/test/files/neg/t1672b.scala
@@ -0,0 +1,41 @@
+object Test {
+ @annotation.tailrec
+ def bar : Nothing = {
+ try {
+ throw new RuntimeException
+ } catch {
+ case _: Throwable => bar
+ } finally {
+ bar
+ }
+ }
+
+ @annotation.tailrec
+ def baz : Nothing = {
+ try {
+ throw new RuntimeException
+ } catch {
+ case _: Throwable => baz
+ } finally {
+ ???
+ }
+ }
+
+ @annotation.tailrec
+ def boz : Nothing = {
+ try {
+ throw new RuntimeException
+ } catch {
+ case _: Throwable => boz; ???
+ }
+ }
+
+ @annotation.tailrec
+ def bez : Nothing = {
+ try {
+ bez
+ } finally {
+ ???
+ }
+ }
+}