You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@annotation.tailrec
deflazyFilter[E](s: Stream[E], p: E=>Boolean):Stream[E] = s match {
case h #:: t =>if (p(h)) h #:: lazyFilter(t, p) else lazyFilter(t, p)
}
In 2.9.0 and 2.9.0.1, I get:
error: could not optimize @tailrec annotated method lazyFilter: it contains a recursive call not in tail position
To my understanding, the method is tail recursive, as the first occurrence of "lazyFilter" is not a call, but a closure that is passed to cons.
I'm not sure if this only a bug in the evaluation of @tailrec, or if the 2.9 compiler really cannot apply tailrec optimization here anymore. In the latter case, it would affect the Stream class as well.