Consider implementing per-tailcall-position tailrec annotation
DarkDimius opened this issue · 1 comments
DarkDimius commented
Consider a method of form
final def foo(a: Int): Int = {
if (foo(a - 1) > 0) foo(a - 1)
else foo(a - 2)
}
During discussion with @sirthias I understood that it's now commonly known tailrec
would actually transform such a method, though it cannot be annotated with @tailrec
as it contains recursive calls in non-tail position.
It would be great if it was possible to annotate specific calls, eg:
final def foo(a: Int): Int = {
if (foo(a - 1) > 0)
foo(a - 1): @tailrec
else
foo(a - 2): @tailrec
}
DarkDimius commented
Implemented in #1227 long time ago.