Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SI-7128 Fix regression in copyToArray for empty arrays

  • Loading branch information...
commit 348ff4b6176a379dba943a6b6e0dbc71410f454f 1 parent cc89bd7
@retronym retronym authored
View
2  src/library/scala/collection/Iterator.scala
@@ -1111,7 +1111,7 @@ 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, s"start $start out of range ${xs.length}")
+ 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)
while (i < end && hasNext) {
View
3  test/files/run/t6827.scala
@@ -28,4 +28,7 @@ object Test extends App {
tryit("read -1", 0, -1)
tryit("invalid read 0", 30, 0)
tryit("invalid read -1", 30, -1)
+
+ // okay, see SI-7128
+ "...".toIterator.copyToArray(new Array[Char](0), 0, 0)
}
Please sign in to comment.
Something went wrong with that request. Please try again.