scala/scala — pull request #3833 by sschaef (2014-06-25 22:09:18+00:00)
Title: SI-8680 Avoid Stream evaluation when it is cyclic

The methods `addString` and `hasDefiniteSize` were too eagerly
implemented in case the Stream references itself and therefore contains
a cycle.

One example of such a Stream is

val s: Stream[Int] = 1 #:: 2 #:: 3 #:: s

The cycle detection is very simple. A reference to the head of the
Stream is stored and in the iteration to reach the end it is checked
if this reference occurs again. If yes further evaluation is aborted.

Review by @ichoran