It seems that the library implementation is not tail recursive override def length: Int = if (isEmpty) 0 else next.length + 1. This seems to be something that could be discussed on the mailing list to see if an extension ticket should be opened.
You can calculate the length as follows:
def length[T](l:LinkedList[T], acc:Int=0): Int =
if (l.isEmpty) acc else length(l.tail, acc + 1)
source
share