diff options
author | Rex Kerr <ichoran@gmail.com> | 2014-08-24 15:51:33 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-01-08 15:14:37 +1000 |
commit | 76619953a628e8c6d3792872a3456260a58d9ffc (patch) | |
tree | 612336e9833779755285a84cac63d0841f0805e6 /src/library/scala/collection/Iterator.scala | |
parent | 333dfbdaafd8fbb7ff0fc3b43060bcc0e4fb989d (diff) | |
download | scala-76619953a628e8c6d3792872a3456260a58d9ffc.tar.gz scala-76619953a628e8c6d3792872a3456260a58d9ffc.tar.bz2 scala-76619953a628e8c6d3792872a3456260a58d9ffc.zip |
SI-7128 copyToArray(xs, 0, 0) should not fail
Fixed all copyToArray methods to do exactly what the docs say
they do, with the least-suprise behavior of not throwing an
exception if you ask to copy nothing (but would have copied out of
range).
Iterator had an undocumented requirement for the target index to
be in range regardless if anything happened; this has been removed.
Diffstat (limited to 'src/library/scala/collection/Iterator.scala')
-rw-r--r-- | src/library/scala/collection/Iterator.scala | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index adb97e27e3..4e3abf2286 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -1187,9 +1187,8 @@ trait Iterator[+A] extends TraversableOnce[A] { * $willNotTerminateInf */ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = { - require(start >= 0 && (start < xs.length || xs.length == 0), s"start $start out of range ${xs.length}") var i = start - val end = start + math.min(len, xs.length - start) + val end = start + math.min(len, xs.length - start) while (i < end && hasNext) { xs(i) = next() i += 1 |