Throw on invalid AbstractMutableList.addAll index #KT-47211

This commit is contained in:
Abduqodiri Qurbonzoda
2021-06-15 04:10:04 +03:00
committed by Space
parent 7e44cddbab
commit 59031543e2
3 changed files with 6 additions and 0 deletions
@@ -35,6 +35,8 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
}
override actual fun addAll(index: Int, elements: Collection<E>): Boolean {
AbstractList.checkPositionIndex(index, size)
var i = index
var changed = false
for (e in elements) {
@@ -35,6 +35,8 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
}
actual override fun addAll(index: Int, elements: Collection<E>): Boolean {
AbstractList.checkPositionIndex(index, size)
checkIsMutable()
var _index = index
var changed = false
@@ -127,6 +127,8 @@ class AbstractCollectionsTest {
assertEquals(listOf("ok", "element"), list)
assertFailsWith<IndexOutOfBoundsException> { list.addAll(-1, listOf()) }
compare(list.storage, list) {
listBehavior()
}