Skip to content

Commit ee1042d

Browse files
committed
Fix inserting at length-1 in ArrayDeque#insertAll
Inserting with `insertAll` just before the last element would actually insert after the last element. Fixes scala/bug#11046
1 parent 19f2280 commit ee1042d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/src/scala/collection/mutable/ArrayDeque.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class ArrayDeque[A] protected (
165165
val n = length
166166
if (idx == 0) {
167167
prependAll(elems)
168-
} else if (idx == n - 1) {
168+
} else if (idx == n) {
169169
addAll(elems)
170170
} else {
171171
// Get both an iterator and the length of the source (by copying the source to an IndexedSeq if needed)

0 commit comments

Comments
 (0)