diff options
author | Paul Phillips <paulp@improving.org> | 2010-01-12 14:11:02 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-01-12 14:11:02 +0000 |
commit | 65c180a5ddccfde0632872df6b118c0fe8293064 (patch) | |
tree | fa28699122de7824fa54e6496450b7d25039ca25 /src/library | |
parent | a6a9f23ec16b153bb4f5c2c86fd79b85a1b06b91 (diff) | |
download | scala-65c180a5ddccfde0632872df6b118c0fe8293064.tar.gz scala-65c180a5ddccfde0632872df6b118c0fe8293064.tar.bz2 scala-65c180a5ddccfde0632872df6b118c0fe8293064.zip |
A fix for at least one manifestation of #2865.
collections and "size" don't mix!
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/IndexedSeqViewLike.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/library/scala/collection/IndexedSeqViewLike.scala b/src/library/scala/collection/IndexedSeqViewLike.scala index 06fa6c8953..5b0b04e5be 100644 --- a/src/library/scala/collection/IndexedSeqViewLike.scala +++ b/src/library/scala/collection/IndexedSeqViewLike.scala @@ -45,7 +45,11 @@ trait IndexedSeqViewLike[+A, trait Zipped[B] extends Transformed[(A, B)] { protected[this] val other: Iterable[B] - def length = self.length min other.size + /** Have to be careful here - other may be an infinite sequence. */ + def length = + if (other.hasDefiniteSize) self.length min other.size + else other take self.length size + def apply(idx: Int): (A, B) = (self.apply(idx), other.iterator drop idx next) override def stringPrefix = self.stringPrefix+"Z" } |