From e05dfaeabf430dac8909ff9e5a5911b0c94101ae Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 10 Jan 2011 07:21:56 +0000 Subject: A pretty severe bug in the recognition of tail ... A pretty severe bug in the recognition of tail call elimination. It turns out that Tailcalls will perform "partial elimination" in situations such as: @annotation.tailrec final def f(x: Int): Int = f(f(x)) The outer call to f1 becomes a jump, but the inner call remains as it was. I implemented @tailrec under the impression that if the optimization had taken place, it had gone all the way. So this is now fixed with a direct examination of the rewritten tree. While I was in there I threw in some improved error reporting: the error positioning is now on the call which is not in tail position rather than the method declaration. Closes #4135, no review. --- test/files/neg/tailrec-2.check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/files/neg/tailrec-2.check') diff --git a/test/files/neg/tailrec-2.check b/test/files/neg/tailrec-2.check index ab6733946d..4f763a1c8d 100644 --- a/test/files/neg/tailrec-2.check +++ b/test/files/neg/tailrec-2.check @@ -1,4 +1,4 @@ -tailrec-2.scala:6: error: could not optimize @tailrec annotated method: it contains a recursive call targetting a supertype +tailrec-2.scala:6: error: could not optimize @tailrec annotated method f: it contains a recursive call targetting a supertype @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) - ^ + ^ one error found -- cgit v1.2.3