diff options
-rw-r--r-- | tests/neg/tailcall/i1221.scala | 10 | ||||
-rw-r--r-- | tests/pos/tailcall/i1221.scala | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/neg/tailcall/i1221.scala b/tests/neg/tailcall/i1221.scala new file mode 100644 index 000000000..5c3286e97 --- /dev/null +++ b/tests/neg/tailcall/i1221.scala @@ -0,0 +1,10 @@ +import annotation.tailrec + +object Test{ + final def foo(a: Int): Int = { + if ((foo(a - 1): @tailrec) > 0) // error: not in tail position + foo(a - 1): @tailrec + else + foo(a - 2): @tailrec + } +} diff --git a/tests/pos/tailcall/i1221.scala b/tests/pos/tailcall/i1221.scala new file mode 100644 index 000000000..80dcfdc4b --- /dev/null +++ b/tests/pos/tailcall/i1221.scala @@ -0,0 +1,10 @@ +import annotation.tailrec + +object Test{ + final def foo(a: Int): Int = { + if (foo(a - 1) > 0) + foo(a - 1): @tailrec + else + foo(a - 2): @tailrec + } +} |