diff options
author | Kota Mizushima <mizukota@gmail.com> | 2012-01-23 17:57:00 +0900 |
---|---|---|
committer | Kota Mizushima <mizukota@gmail.com> | 2012-01-23 17:57:00 +0900 |
commit | eadc8db056ee5165cefbf221c0d8e2e67ba147cf (patch) | |
tree | e9fef3f14befd7502a9ecdb894dda9c56772a9ed /src | |
parent | 9a20086495e7734b636c5ee625d305a3fbaea476 (diff) | |
download | scala-eadc8db056ee5165cefbf221c0d8e2e67ba147cf.tar.gz scala-eadc8db056ee5165cefbf221c0d8e2e67ba147cf.tar.bz2 scala-eadc8db056ee5165cefbf221c0d8e2e67ba147cf.zip |
* Fixed SI-4835 (https://issues.scala-lang.org/browse/SI-4835).
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/Stream.scala | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index e6587f9615..2eb2f8eb09 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -929,13 +929,19 @@ self => /** A specialized, extra-lazy implementation of a stream iterator, so it can * iterate as lazily as it traverses the tail. */ -final class StreamIterator[+A](self: Stream[A]) extends AbstractIterator[A] with Iterator[A] { +final class StreamIterator[+A] private() extends AbstractIterator[A] with Iterator[A] { + def this(self: Stream[A]) { + this() + these = new LazyCell(self) + } + // A call-by-need cell. class LazyCell(st: => Stream[A]) { lazy val v = st } - private var these = new LazyCell(self) + private var these: LazyCell = _ + def hasNext: Boolean = these.v.nonEmpty def next(): A = if (isEmpty) Iterator.empty.next |