summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2012-12-10 12:19:43 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2012-12-10 12:19:43 -0800
commit84eff4d144e1523f1a51ffca77eb983a29eccd72 (patch)
tree09f26a6add77fa574a53c95b6814e62fd8a6bbc7 /test/files/neg
parent6f121da8902ea0b7a778f1ae1e690490330ba2ca (diff)
parent8434922d6f0ead95a2109a5e41f4db4136449e93 (diff)
downloadscala-84eff4d144e1523f1a51ffca77eb983a29eccd72.tar.gz
scala-84eff4d144e1523f1a51ffca77eb983a29eccd72.tar.bz2
scala-84eff4d144e1523f1a51ffca77eb983a29eccd72.zip
Merge pull request #1711 from retronym/ticket/1672
SI-1672 Catches are in tail position without finally.
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/t1672b.check16
-rw-r--r--test/files/neg/t1672b.scala52
2 files changed, 68 insertions, 0 deletions
diff --git a/test/files/neg/t1672b.check b/test/files/neg/t1672b.check
new file mode 100644
index 0000000000..60ccf77174
--- /dev/null
+++ b/test/files/neg/t1672b.check
@@ -0,0 +1,16 @@
+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 = {
+ ^
+t1672b.scala:46: error: could not optimize @tailrec annotated method bar: it contains a recursive call not in tail position
+ else 1 + (try {
+ ^
+5 errors found
diff --git a/test/files/neg/t1672b.scala b/test/files/neg/t1672b.scala
new file mode 100644
index 0000000000..0ccdd03633
--- /dev/null
+++ b/test/files/neg/t1672b.scala
@@ -0,0 +1,52 @@
+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 {
+ ???
+ }
+ }
+
+ // the `liftedTree` local method will prevent a tail call here.
+ @annotation.tailrec
+ def bar(i : Int) : Int = {
+ if (i == 0) 0
+ else 1 + (try {
+ throw new RuntimeException
+ } catch {
+ case _: Throwable => bar(i - 1)
+ })
+ }
+}