For those trying to recreate a compiler error in REPL, you need to wrap the method in a class like this:
class Test { @annotation.tailrec def areStreamsEqual(stream1: InputStream, stream2: InputStream): Boolean = { val one = stream1.read() val two = stream2.read() if(one != two) false else if(one == -1 && two == -1) true else areStreamsEqual(stream1, stream2) } }
If you just connect the method to REPL, it will be TCO'd just fine, since the method outside the class cannot be overridden.
source share