summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorKota Mizushima <mizukota@gmail.com>2012-01-23 17:57:00 +0900
committerKota Mizushima <mizukota@gmail.com>2012-01-23 17:57:00 +0900
commiteadc8db056ee5165cefbf221c0d8e2e67ba147cf (patch)
treee9fef3f14befd7502a9ecdb894dda9c56772a9ed /src/library
parent9a20086495e7734b636c5ee625d305a3fbaea476 (diff)
downloadscala-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/library')
-rw-r--r--src/library/scala/collection/immutable/Stream.scala10
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