diff --git a/libraries/stdlib/src/kotlin/ImmutableArrayList.kt b/libraries/stdlib/src/kotlin/ImmutableArrayList.kt index 01a3967010f..4cacab1b8f6 100644 --- a/libraries/stdlib/src/kotlin/ImmutableArrayList.kt +++ b/libraries/stdlib/src/kotlin/ImmutableArrayList.kt @@ -11,24 +11,24 @@ private class ImmutableArrayList( { // impossible if (offset < 0) { - throw IllegalArgumentException("negative offset") + throw IllegalArgumentException("negative offset ($offset)") } // impossible if (length < 0) { - throw IllegalArgumentException("negative length") + throw IllegalArgumentException("negative length ($length)") } // possible when builder is used from different threads if (offset + length > array.size) { - throw IllegalArgumentException("offset + length > array.length") + throw IllegalArgumentException("offset ($offset) + length ($length) > array.length (${array.size})") } } protected fun indexInArray(index: Int): Int { if (index < 0) { - throw IllegalArgumentException("negative index") + throw IndexOutOfBoundsException("negative index ($index)") } if (index >= length) { - throw IllegalArgumentException("index > length") + throw IndexOutOfBoundsException("index ($index) >= length ($length)") } return index + offset } @@ -39,13 +39,13 @@ private class ImmutableArrayList( public override fun subList(fromIndex: Int, toIndex: Int) : List { if (fromIndex < 0) { - throw IllegalArgumentException("negative from index") + throw IndexOutOfBoundsException("negative from index ($fromIndex)") } if (toIndex < fromIndex) { - throw IllegalArgumentException("toIndex < fromIndex") + throw IndexOutOfBoundsException("toIndex ($toIndex) < fromIndex ($fromIndex)") } if (toIndex > length) { - throw IllegalArgumentException("fromIndex + toIndex > length") + throw IndexOutOfBoundsException("fromIndex ($fromIndex) + toIndex ($toIndex) > length ($length)") } return ImmutableArrayList(array, offset + fromIndex, toIndex - fromIndex) } diff --git a/libraries/stdlib/test/ImmutableArrayListTest.kt b/libraries/stdlib/test/ImmutableArrayListTest.kt index d3ec1058160..a6b09c439e7 100644 --- a/libraries/stdlib/test/ImmutableArrayListTest.kt +++ b/libraries/stdlib/test/ImmutableArrayListTest.kt @@ -42,7 +42,7 @@ class ImmutableArrayListTest() : TestCase() { try { list[expectedLength] fail() - } catch (e: IllegalArgumentException) { + } catch (e: IndexOutOfBoundsException) { // expected } }