diff --git a/kotlin-native/backend.native/tests/codegen/bce/arraysForLoops.kt b/kotlin-native/backend.native/tests/codegen/bce/arraysForLoops.kt index bb1589bfcf0..d5ddb723d90 100644 --- a/kotlin-native/backend.native/tests/codegen/bce/arraysForLoops.kt +++ b/kotlin-native/backend.native/tests/codegen/bce/arraysForLoops.kt @@ -10,7 +10,7 @@ import kotlin.reflect.KProperty @Test fun forEachIndexedTest() { val array = Array(10) { 0 } - assertFailsWith { + assertFailsWith { array.forEachIndexed { index, _ -> array[index + 1] = 1 } @@ -22,20 +22,20 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0 } var j = 4 - assertFailsWith { + assertFailsWith { for (i in array.indices) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for (i in array.indices) { array[i + 1] = 6 } } - assertFailsWith { + assertFailsWith { for (i in array.indices) { array1[i] = 6 } @@ -47,26 +47,26 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0L } var j = 4 - assertFailsWith { + assertFailsWith { for (i in 0 until array.size) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for (i in 0 until array.size) { array[i - 1] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0 until array.size) { array1[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0 until array.size + 10) { array[i] = 6 } @@ -78,20 +78,20 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0L } var j = 4 - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo 0) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo 0) { array[i * 2] = 6 } } - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo 0) { array1[i] = 6 } @@ -101,25 +101,25 @@ import kotlin.reflect.KProperty val b = ++a val c = b - assertFailsWith { + assertFailsWith { for (i in c downTo 0) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in array.size + 1 downTo 0) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo -1) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in array.size downTo 0) { array[i] = 6 } @@ -131,7 +131,7 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0L } var j = 4 - assertFailsWith { + assertFailsWith { for (i in 0..array.size - 1) { array[j] = 6 j++ @@ -140,37 +140,37 @@ import kotlin.reflect.KProperty var length = array.size - 1 length = 2 * length - assertFailsWith { + assertFailsWith { for (i in 0..length) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size - 1) { array[i + 1] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size - 1) { array1[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size + 1) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in -1..array.size - 1) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size) { array[i] = 6 } @@ -182,38 +182,38 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0L } var j = 8 - assertFailsWith { + assertFailsWith { for (i in 0..array.size - 1 step 2) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size - 1 step 2) { array[i - 1] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size - 1 step 2) { array1[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size + 1 step 2) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in -1..array.size - 1 step 2) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in 0..array.size step 2) { array[i] = 6 } @@ -225,32 +225,32 @@ import kotlin.reflect.KProperty val array1 = CharArray(3) { '0' } var j = 8 - assertFailsWith { + assertFailsWith { for (i in 0 until array.size step 2) { array[j] = '6' j++ } } - assertFailsWith { + assertFailsWith { for (i in 0 until array.size step 2) { array[i + 3] = '6' } } - assertFailsWith { + assertFailsWith { for (i in 0 until array.size step 2) { array1[i] = '6' } } - assertFailsWith { + assertFailsWith { for (i in 0 until (array.size/0.5).toInt() step 2) { array[i] = '6' } } - assertFailsWith { + assertFailsWith { for (i in -array.size until array.size step 2) { array[i] = '6' } @@ -262,38 +262,38 @@ import kotlin.reflect.KProperty val array1 = UIntArray(3) { 0U } var j = 8 - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo 0 step 2) { array[j] = 6U j++ } } - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo 1 step 2) { array[i + 1] = 6U } } - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo 1 step 2) { array1[i] = 6U } } - assertFailsWith { + assertFailsWith { for (i in (array.size / 0.2).toInt() downTo 1 step 2) { array[i] = 6U } } - assertFailsWith { + assertFailsWith { for (i in array.size - 1 downTo -3 step 2) { array[i] = 6U } } - assertFailsWith { + assertFailsWith { for (i in array.size downTo 1 step 2) { array[i] = 6U } @@ -305,20 +305,20 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0L } var j = 8 - assertFailsWith { + assertFailsWith { for (i in array.indices step 2) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for (i in array.indices step 2) { array[i - 1] = 6 } } - assertFailsWith { + assertFailsWith { for (i in array.indices step 2) { array1[i] = 6 } @@ -330,32 +330,32 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0 } var j = 8 - assertFailsWith { + assertFailsWith { for ((index, value) in array.withIndex()) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for ((index, value) in array.withIndex()) { array[index + 1] = 6 } } - assertFailsWith { + assertFailsWith { for ((index, value) in array.withIndex()) { array[value] = 6 } } - assertFailsWith { + assertFailsWith { for ((i, v) in (0..array.size + 30 step 2).withIndex()) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for ((i, v) in (0..array.size).withIndex()) { array[v] = 8 } @@ -367,26 +367,26 @@ import kotlin.reflect.KProperty val array1 = Array(3) { 0 } var j = 8 - assertFailsWith { + assertFailsWith { for (i in (0..array.size-1).reversed()) { array[j] = 6 j++ } } - assertFailsWith { + assertFailsWith { for (i in (0 until array.size).reversed()) { array1[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in (0..array.size).reversed()) { array[i] = 6 } } - assertFailsWith { + assertFailsWith { for (i in (array.size downTo 0).reversed()) { array[i] = 6 } @@ -511,7 +511,7 @@ class Child : Base() { @Test fun withGetter() { val obj = WithGetter() needSmallArray = false - assertFailsWith { + assertFailsWith { for (i in 0..obj.array.size-1) { needSmallArray = true obj.array[i] = 6 @@ -523,7 +523,7 @@ class Child : Base() { @Test fun delegatedProperty() { val obj = WithDelegates() needSmallArray = false - assertFailsWith { + assertFailsWith { for (i in 0..obj.array.size-1) { needSmallArray = true obj.array[i] = 6 @@ -536,7 +536,7 @@ class Child : Base() { val obj = Child() val base = Base() needSmallArray = false - assertFailsWith { + assertFailsWith { for (i in 0..obj.array.size-1) { needSmallArray = true obj.array[i] = 6 @@ -545,7 +545,7 @@ class Child : Base() { } needSmallArray = false - assertFailsWith { + assertFailsWith { for (i in 0..obj.array1.size-1) { needSmallArray = true obj.array1[i] = 6 @@ -554,7 +554,7 @@ class Child : Base() { } needSmallArray = false - assertFailsWith { + assertFailsWith { for (i in 0..obj.array.size-1) { needSmallArray = true base.array[i] = 6 @@ -569,7 +569,7 @@ val array: Array = arrayOf(1) @Test fun customeGetter() { val a = array needSmallArray = false - assertFailsWith { + assertFailsWith { for (index in 0 until array.size) { a[index] = 6 } @@ -592,7 +592,7 @@ class Third(initArray: Array) { val a = Third(arrayOf(1, 2, 3, 4, 5)) val b = Third(arrayOf(1, 2)) - assertFailsWith { + assertFailsWith { for (i in 0..a.second.first.array.size-1) { b.second.first.array[i] = 6 } @@ -614,7 +614,7 @@ class Bar { @Test fun differentArrays() { val bar = Bar() - assertFailsWith { + assertFailsWith { for (index in 0 until bar.largeArray.size) { bar.smallArray[index] = 6 } diff --git a/kotlin-native/backend.native/tests/codegen/initializers/static.kt b/kotlin-native/backend.native/tests/codegen/initializers/static.kt index c7ffe900eb2..75cc82e8a4f 100644 --- a/kotlin-native/backend.native/tests/codegen/initializers/static.kt +++ b/kotlin-native/backend.native/tests/codegen/initializers/static.kt @@ -54,7 +54,7 @@ fun f() = 5 assertEquals(20, varargGetter(2, 2, 3, 4)) assertEquals(20, varargGetter(2, 2, 3, 4)) if (Platform.osFamily != OsFamily.WASM) { - assertFailsWith { varargGetter(3, 2, 3, 4) } + assertFailsWith { varargGetter(3, 2, 3, 4) } } } } diff --git a/kotlin-native/backend.native/tests/interop/basics/pinning.kt b/kotlin-native/backend.native/tests/interop/basics/pinning.kt index 0bc48331552..ba1836dea0a 100644 --- a/kotlin-native/backend.native/tests/interop/basics/pinning.kt +++ b/kotlin-native/backend.native/tests/interop/basics/pinning.kt @@ -11,16 +11,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0, it.addressOf(0).pointed.value) assertEquals(0, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -31,16 +31,16 @@ import kotlinx.cinterop.* str.usePinned { it.addressOf(0) it.addressOf(9) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -51,16 +51,16 @@ import kotlinx.cinterop.* arr.usePinned { it.addressOf(0) it.addressOf(9) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -71,16 +71,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0, it.addressOf(0).pointed.value) assertEquals(0, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -91,16 +91,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0, it.addressOf(0).pointed.value) assertEquals(0, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -111,16 +111,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0, it.addressOf(0).pointed.value) assertEquals(0, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -131,16 +131,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0U, it.addressOf(0).pointed.value) assertEquals(0U, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -151,16 +151,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0U, it.addressOf(0).pointed.value) assertEquals(0U, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -171,16 +171,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0U, it.addressOf(0).pointed.value) assertEquals(0U, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -191,16 +191,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0U, it.addressOf(0).pointed.value) assertEquals(0U, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -211,16 +211,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0.0f, it.addressOf(0).pointed.value) assertEquals(0.0f, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } @@ -231,16 +231,16 @@ import kotlinx.cinterop.* arr.usePinned { assertEquals(0.0, it.addressOf(0).pointed.value) assertEquals(0.0, it.addressOf(9).pointed.value) - assertFailsWith { + assertFailsWith { it.addressOf(10) } - assertFailsWith { + assertFailsWith { it.addressOf(-1) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { it.addressOf(Int.MIN_VALUE) } } diff --git a/kotlin-native/backend.native/tests/runtime/collections/array5.kt b/kotlin-native/backend.native/tests/runtime/collections/array5.kt index 8cc1b18fab1..6b930a461e1 100644 --- a/kotlin-native/backend.native/tests/runtime/collections/array5.kt +++ b/kotlin-native/backend.native/tests/runtime/collections/array5.kt @@ -12,16 +12,16 @@ import kotlinx.cinterop.* val arr = Array(10) { 0 } assertEquals(0, arr[0]) assertEquals(0, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -30,16 +30,16 @@ import kotlinx.cinterop.* val arr = Array(10) { 0 } arr[0] = 1 arr[9] = 1 - assertFailsWith { + assertFailsWith { arr[10] = 1 } - assertFailsWith { + assertFailsWith { arr[-1] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1 } } @@ -48,16 +48,16 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0, arr[0]) assertEquals(0, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -66,16 +66,16 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr[0] = 1 arr[9] = 1 - assertFailsWith { + assertFailsWith { arr[10] = 1 } - assertFailsWith { + assertFailsWith { arr[-1] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1 } } @@ -84,16 +84,16 @@ import kotlinx.cinterop.* val arr = UByteArray(10) { 0U } assertEquals(0U, arr[0]) assertEquals(0U, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -102,16 +102,16 @@ import kotlinx.cinterop.* val arr = UByteArray(10) { 0U } arr[0] = 1U arr[9] = 1U - assertFailsWith { + assertFailsWith { arr[10] = 1U } - assertFailsWith { + assertFailsWith { arr[-1] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1U } } @@ -120,16 +120,16 @@ import kotlinx.cinterop.* val arr = ShortArray(10) { 0 } assertEquals(0, arr[0]) assertEquals(0, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -138,16 +138,16 @@ import kotlinx.cinterop.* val arr = ShortArray(10) { 0 } arr[0] = 1 arr[9] = 1 - assertFailsWith { + assertFailsWith { arr[10] = 1 } - assertFailsWith { + assertFailsWith { arr[-1] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1 } } @@ -156,16 +156,16 @@ import kotlinx.cinterop.* val arr = UShortArray(10) { 0U } assertEquals(0U, arr[0]) assertEquals(0U, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -174,16 +174,16 @@ import kotlinx.cinterop.* val arr = UShortArray(10) { 0U } arr[0] = 1U arr[9] = 1U - assertFailsWith { + assertFailsWith { arr[10] = 1U } - assertFailsWith { + assertFailsWith { arr[-1] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1U } } @@ -192,16 +192,16 @@ import kotlinx.cinterop.* val arr = IntArray(10) { 0 } assertEquals(0, arr[0]) assertEquals(0, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -210,16 +210,16 @@ import kotlinx.cinterop.* val arr = IntArray(10) { 0 } arr[0] = 1 arr[9] = 1 - assertFailsWith { + assertFailsWith { arr[10] = 1 } - assertFailsWith { + assertFailsWith { arr[-1] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1 } } @@ -228,16 +228,16 @@ import kotlinx.cinterop.* val arr = UIntArray(10) { 0U } assertEquals(0U, arr[0]) assertEquals(0U, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -246,16 +246,16 @@ import kotlinx.cinterop.* val arr = UIntArray(10) { 0U } arr[0] = 1U arr[9] = 1U - assertFailsWith { + assertFailsWith { arr[10] = 1U } - assertFailsWith { + assertFailsWith { arr[-1] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1U } } @@ -264,16 +264,16 @@ import kotlinx.cinterop.* val arr = LongArray(10) { 0 } assertEquals(0, arr[0]) assertEquals(0, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -282,16 +282,16 @@ import kotlinx.cinterop.* val arr = LongArray(10) { 0 } arr[0] = 1 arr[9] = 1 - assertFailsWith { + assertFailsWith { arr[10] = 1 } - assertFailsWith { + assertFailsWith { arr[-1] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1 } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1 } } @@ -300,16 +300,16 @@ import kotlinx.cinterop.* val arr = ULongArray(10) { 0U } assertEquals(0U, arr[0]) assertEquals(0U, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -318,16 +318,16 @@ import kotlinx.cinterop.* val arr = ULongArray(10) { 0U } arr[0] = 1U arr[9] = 1U - assertFailsWith { + assertFailsWith { arr[10] = 1U } - assertFailsWith { + assertFailsWith { arr[-1] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1U } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1U } } @@ -336,16 +336,16 @@ import kotlinx.cinterop.* val arr = FloatArray(10) { 0.0f } assertEquals(0.0f, arr[0]) assertEquals(0.0f, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -354,16 +354,16 @@ import kotlinx.cinterop.* val arr = FloatArray(10) { 0.0f } arr[0] = 1.0f arr[9] = 1.0f - assertFailsWith { + assertFailsWith { arr[10] = 1.0f } - assertFailsWith { + assertFailsWith { arr[-1] = 1.0f } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1.0f } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1.0f } } @@ -372,16 +372,16 @@ import kotlinx.cinterop.* val arr = DoubleArray(10) { 0.0 } assertEquals(0.0, arr[0]) assertEquals(0.0, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -390,16 +390,16 @@ import kotlinx.cinterop.* val arr = DoubleArray(10) { 0.0 } arr[0] = 1.0 arr[9] = 1.0 - assertFailsWith { + assertFailsWith { arr[10] = 1.0 } - assertFailsWith { + assertFailsWith { arr[-1] = 1.0 } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = 1.0 } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = 1.0 } } @@ -408,16 +408,16 @@ import kotlinx.cinterop.* val arr = BooleanArray(10) { false } assertEquals(false, arr[0]) assertEquals(false, arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -426,16 +426,16 @@ import kotlinx.cinterop.* val arr = BooleanArray(10) { false } arr[0] = true arr[9] = true - assertFailsWith { + assertFailsWith { arr[10] = true } - assertFailsWith { + assertFailsWith { arr[-1] = true } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = true } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = true } } @@ -444,16 +444,16 @@ import kotlinx.cinterop.* val arr = CharArray(10) { '0' } assertEquals('0', arr[0]) assertEquals('0', arr[9]) - assertFailsWith { + assertFailsWith { arr[10] } - assertFailsWith { + assertFailsWith { arr[-1] } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] } } @@ -462,16 +462,16 @@ import kotlinx.cinterop.* val arr = CharArray(10) { '0' } arr[0] = '1' arr[9] = '1' - assertFailsWith { + assertFailsWith { arr[10] = '1' } - assertFailsWith { + assertFailsWith { arr[-1] = '1' } - assertFailsWith { + assertFailsWith { arr[Int.MAX_VALUE] = '1' } - assertFailsWith { + assertFailsWith { arr[Int.MIN_VALUE] = '1' } } @@ -480,16 +480,16 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0U, arr.getUByteAt(0)) assertEquals(0U, arr.getUByteAt(9)) - assertFailsWith { + assertFailsWith { arr.getUByteAt(10) } - assertFailsWith { + assertFailsWith { arr.getUByteAt(-1) } - assertFailsWith { + assertFailsWith { arr.getUByteAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getUByteAt(Int.MIN_VALUE) } } @@ -498,16 +498,16 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setUByteAt(0, 1U) arr.setUByteAt(9, 1U) - assertFailsWith { + assertFailsWith { arr.setUByteAt(10, 1U) } - assertFailsWith { + assertFailsWith { arr.setUByteAt(-1, 1U) } - assertFailsWith { + assertFailsWith { arr.setUByteAt(Int.MAX_VALUE, 1U) } - assertFailsWith { + assertFailsWith { arr.setUByteAt(Int.MIN_VALUE, 1U) } } @@ -516,19 +516,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0.toChar(), arr.getCharAt(0)) assertEquals(0.toChar(), arr.getCharAt(8)) - assertFailsWith { + assertFailsWith { arr.getCharAt(9) } - assertFailsWith { + assertFailsWith { arr.getCharAt(10) } - assertFailsWith { + assertFailsWith { arr.getCharAt(-1) } - assertFailsWith { + assertFailsWith { arr.getCharAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getCharAt(Int.MIN_VALUE) } } @@ -537,19 +537,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setCharAt(0, '1') arr.setCharAt(8, '1') - assertFailsWith { + assertFailsWith { arr.setCharAt(9, '1') } - assertFailsWith { + assertFailsWith { arr.setCharAt(10, '1') } - assertFailsWith { + assertFailsWith { arr.setCharAt(-1, '1') } - assertFailsWith { + assertFailsWith { arr.setCharAt(Int.MAX_VALUE, '1') } - assertFailsWith { + assertFailsWith { arr.setCharAt(Int.MIN_VALUE, '1') } } @@ -558,19 +558,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0, arr.getShortAt(0)) assertEquals(0, arr.getShortAt(8)) - assertFailsWith { + assertFailsWith { arr.getShortAt(9) } - assertFailsWith { + assertFailsWith { arr.getShortAt(10) } - assertFailsWith { + assertFailsWith { arr.getShortAt(-1) } - assertFailsWith { + assertFailsWith { arr.getShortAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getShortAt(Int.MIN_VALUE) } } @@ -579,19 +579,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setShortAt(0, 0) arr.setShortAt(8, 0) - assertFailsWith { + assertFailsWith { arr.setShortAt(9, 1) } - assertFailsWith { + assertFailsWith { arr.setShortAt(10, 1) } - assertFailsWith { + assertFailsWith { arr.setShortAt(-1, 1) } - assertFailsWith { + assertFailsWith { arr.setShortAt(Int.MAX_VALUE, 1) } - assertFailsWith { + assertFailsWith { arr.setShortAt(Int.MIN_VALUE, 1) } } @@ -600,19 +600,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0U, arr.getUShortAt(0)) assertEquals(0U, arr.getUShortAt(8)) - assertFailsWith { + assertFailsWith { arr.getUShortAt(9) } - assertFailsWith { + assertFailsWith { arr.getUShortAt(10) } - assertFailsWith { + assertFailsWith { arr.getUShortAt(-1) } - assertFailsWith { + assertFailsWith { arr.getUShortAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getUShortAt(Int.MIN_VALUE) } } @@ -621,19 +621,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setUShortAt(0, 0U) arr.setUShortAt(8, 0U) - assertFailsWith { + assertFailsWith { arr.setUShortAt(9, 1U) } - assertFailsWith { + assertFailsWith { arr.setUShortAt(10, 1U) } - assertFailsWith { + assertFailsWith { arr.setUShortAt(-1, 1U) } - assertFailsWith { + assertFailsWith { arr.setUShortAt(Int.MAX_VALUE, 1U) } - assertFailsWith { + assertFailsWith { arr.setUShortAt(Int.MIN_VALUE, 1U) } } @@ -642,19 +642,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0, arr.getIntAt(0)) assertEquals(0, arr.getIntAt(6)) - assertFailsWith { + assertFailsWith { arr.getIntAt(7) } - assertFailsWith { + assertFailsWith { arr.getIntAt(10) } - assertFailsWith { + assertFailsWith { arr.getIntAt(-1) } - assertFailsWith { + assertFailsWith { arr.getIntAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getIntAt(Int.MIN_VALUE) } } @@ -663,19 +663,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setIntAt(0, 1) arr.setIntAt(6, 1) - assertFailsWith { + assertFailsWith { arr.setIntAt(7, 1) } - assertFailsWith { + assertFailsWith { arr.setIntAt(10, 1) } - assertFailsWith { + assertFailsWith { arr.setIntAt(-1, 1) } - assertFailsWith { + assertFailsWith { arr.setIntAt(Int.MAX_VALUE, 1) } - assertFailsWith { + assertFailsWith { arr.setIntAt(Int.MIN_VALUE, 1) } } @@ -684,19 +684,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0U, arr.getUIntAt(0)) assertEquals(0U, arr.getUIntAt(6)) - assertFailsWith { + assertFailsWith { arr.getUIntAt(7) } - assertFailsWith { + assertFailsWith { arr.getUIntAt(10) } - assertFailsWith { + assertFailsWith { arr.getUIntAt(-1) } - assertFailsWith { + assertFailsWith { arr.getUIntAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getUIntAt(Int.MIN_VALUE) } } @@ -705,19 +705,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setUIntAt(0, 1U) arr.setUIntAt(6, 1U) - assertFailsWith { + assertFailsWith { arr.setUIntAt(7, 1U) } - assertFailsWith { + assertFailsWith { arr.setUIntAt(10, 1U) } - assertFailsWith { + assertFailsWith { arr.setUIntAt(-1, 1U) } - assertFailsWith { + assertFailsWith { arr.setUIntAt(Int.MAX_VALUE, 1U) } - assertFailsWith { + assertFailsWith { arr.setUIntAt(Int.MIN_VALUE, 1U) } } @@ -726,19 +726,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0, arr.getLongAt(0)) assertEquals(0, arr.getLongAt(2)) - assertFailsWith { + assertFailsWith { arr.getLongAt(3) } - assertFailsWith { + assertFailsWith { arr.getLongAt(10) } - assertFailsWith { + assertFailsWith { arr.getLongAt(-1) } - assertFailsWith { + assertFailsWith { arr.getLongAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getLongAt(Int.MIN_VALUE) } } @@ -747,19 +747,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setLongAt(0, 1) arr.setLongAt(2, 1) - assertFailsWith { + assertFailsWith { arr.setLongAt(3, 1) } - assertFailsWith { + assertFailsWith { arr.setLongAt(10, 1) } - assertFailsWith { + assertFailsWith { arr.setLongAt(-1, 1) } - assertFailsWith { + assertFailsWith { arr.setLongAt(Int.MAX_VALUE, 1) } - assertFailsWith { + assertFailsWith { arr.setLongAt(Int.MIN_VALUE, 1) } } @@ -768,19 +768,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0U, arr.getULongAt(0)) assertEquals(0U, arr.getULongAt(2)) - assertFailsWith { + assertFailsWith { arr.getULongAt(3) } - assertFailsWith { + assertFailsWith { arr.getULongAt(10) } - assertFailsWith { + assertFailsWith { arr.getULongAt(-1) } - assertFailsWith { + assertFailsWith { arr.getULongAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getULongAt(Int.MIN_VALUE) } } @@ -789,19 +789,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setULongAt(0, 1U) arr.setULongAt(2, 1U) - assertFailsWith { + assertFailsWith { arr.setULongAt(3, 1U) } - assertFailsWith { + assertFailsWith { arr.setULongAt(10, 1U) } - assertFailsWith { + assertFailsWith { arr.setULongAt(-1, 1U) } - assertFailsWith { + assertFailsWith { arr.setULongAt(Int.MAX_VALUE, 1U) } - assertFailsWith { + assertFailsWith { arr.setULongAt(Int.MIN_VALUE, 1U) } } @@ -810,19 +810,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0.0f, arr.getFloatAt(0)) assertEquals(0.0f, arr.getFloatAt(6)) - assertFailsWith { + assertFailsWith { arr.getFloatAt(7) } - assertFailsWith { + assertFailsWith { arr.getFloatAt(10) } - assertFailsWith { + assertFailsWith { arr.getFloatAt(-1) } - assertFailsWith { + assertFailsWith { arr.getFloatAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getFloatAt(Int.MIN_VALUE) } } @@ -831,19 +831,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setFloatAt(0, 1.0f) arr.setFloatAt(6, 1.0f) - assertFailsWith { + assertFailsWith { arr.setFloatAt(7, 1.0f) } - assertFailsWith { + assertFailsWith { arr.setFloatAt(10, 1.0f) } - assertFailsWith { + assertFailsWith { arr.setFloatAt(-1, 1.0f) } - assertFailsWith { + assertFailsWith { arr.setFloatAt(Int.MAX_VALUE, 1.0f) } - assertFailsWith { + assertFailsWith { arr.setFloatAt(Int.MIN_VALUE, 1.0f) } } @@ -852,19 +852,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } assertEquals(0.0, arr.getDoubleAt(0)) assertEquals(0.0, arr.getDoubleAt(2)) - assertFailsWith { + assertFailsWith { arr.getDoubleAt(3) } - assertFailsWith { + assertFailsWith { arr.getDoubleAt(10) } - assertFailsWith { + assertFailsWith { arr.getDoubleAt(-1) } - assertFailsWith { + assertFailsWith { arr.getDoubleAt(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { arr.getDoubleAt(Int.MIN_VALUE) } } @@ -873,19 +873,19 @@ import kotlinx.cinterop.* val arr = ByteArray(10) { 0 } arr.setDoubleAt(0, 1.0) arr.setDoubleAt(2, 1.0) - assertFailsWith { + assertFailsWith { arr.setDoubleAt(3, 1.0) } - assertFailsWith { + assertFailsWith { arr.setDoubleAt(10, 1.0) } - assertFailsWith { + assertFailsWith { arr.setDoubleAt(-1, 1.0) } - assertFailsWith { + assertFailsWith { arr.setDoubleAt(Int.MAX_VALUE, 1.0) } - assertFailsWith { + assertFailsWith { arr.setDoubleAt(Int.MIN_VALUE, 1.0) } } @@ -895,19 +895,19 @@ import kotlinx.cinterop.* val arr = blob.toByteArray(0, 1) assertEquals(1, arr.size) assertEquals(0, arr[0]) - assertFailsWith { + assertFailsWith { blob.toByteArray(-1, 1) } - assertFailsWith { + assertFailsWith { blob.toByteArray(0, -1) } - assertFailsWith { + assertFailsWith { blob.toByteArray(0, 10) } - assertFailsWith { + assertFailsWith { blob.toByteArray(10, 11) } - assertFailsWith { + assertFailsWith { blob.toByteArray(10, 1) } } @@ -917,19 +917,19 @@ import kotlinx.cinterop.* val arr = blob.toUByteArray(0, 1) assertEquals(1, arr.size) assertEquals(0U, arr[0]) - assertFailsWith { + assertFailsWith { blob.toUByteArray(-1, 1) } - assertFailsWith { + assertFailsWith { blob.toUByteArray(0, -1) } - assertFailsWith { + assertFailsWith { blob.toUByteArray(0, 10) } - assertFailsWith { + assertFailsWith { blob.toUByteArray(10, 11) } - assertFailsWith { + assertFailsWith { blob.toUByteArray(10, 1) } } @@ -937,16 +937,16 @@ import kotlinx.cinterop.* @Test fun immutableBlobAsCPointer() { val blob = immutableBlobOf(0, 0) assertEquals(0, blob.asCPointer(0).pointed.value) - assertFailsWith { + assertFailsWith { blob.asCPointer(10) } - assertFailsWith { + assertFailsWith { blob.asCPointer(-1) } - assertFailsWith { + assertFailsWith { blob.asCPointer(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { blob.asCPointer(Int.MIN_VALUE) } } @@ -954,16 +954,16 @@ import kotlinx.cinterop.* @Test fun immutableBlobAsUCPointer() { val blob = immutableBlobOf(0, 0) assertEquals(0U, blob.asUCPointer(0).pointed.value) - assertFailsWith { + assertFailsWith { blob.asUCPointer(10) } - assertFailsWith { + assertFailsWith { blob.asUCPointer(-1) } - assertFailsWith { + assertFailsWith { blob.asUCPointer(Int.MAX_VALUE) } - assertFailsWith { + assertFailsWith { blob.asUCPointer(Int.MIN_VALUE) } } diff --git a/kotlin-native/backend.native/tests/runtime/collections/typed_array1.kt b/kotlin-native/backend.native/tests/runtime/collections/typed_array1.kt index fb11068f4a2..c21af9769a1 100644 --- a/kotlin-native/backend.native/tests/runtime/collections/typed_array1.kt +++ b/kotlin-native/backend.native/tests/runtime/collections/typed_array1.kt @@ -13,40 +13,40 @@ import kotlin.native.concurrent.* val array = ByteArray(17) val results = mutableSetOf() var counter = 0 - assertFailsWith { + assertFailsWith { results += array.getShortAt(16) } - assertFailsWith { + assertFailsWith { results += array.getCharAt(22) } - assertFailsWith { + assertFailsWith { results += array.getIntAt(15) } - assertFailsWith { + assertFailsWith { results += array.getLongAt(14) } - assertFailsWith { + assertFailsWith { results += array.getFloatAt(14) } - assertFailsWith { + assertFailsWith { results += array.getDoubleAt(13) } - assertFailsWith { + assertFailsWith { array.setShortAt(16, 2.toShort()) } - assertFailsWith { + assertFailsWith { array.setCharAt(22, 'a') } - assertFailsWith { + assertFailsWith { array.setIntAt(15, 1234) } - assertFailsWith { + assertFailsWith { array.setLongAt(14, 1.toLong()) } - assertFailsWith { + assertFailsWith { array.setFloatAt(14, 1.0f) } - assertFailsWith { + assertFailsWith { array.setDoubleAt(13, 3.0) } expect(0) { results.size } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt index f35fd2fc5ec..0d8dafc7575 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt @@ -92,6 +92,8 @@ public actual open class IndexOutOfBoundsException : RuntimeException { actual constructor(message: String?) : super(message) } +@Deprecated("Use IndexOutOfBoundsException instead.") +@DeprecatedSinceKotlin(warningSince = "1.9") public open class ArrayIndexOutOfBoundsException : IndexOutOfBoundsException { constructor() : super() diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/TypedArrays.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/TypedArrays.kt index 1404ec3ec22..b0c22228c7b 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/TypedArrays.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/TypedArrays.kt @@ -9,33 +9,33 @@ import kotlin.native.internal.GCUnsafeCall /** * Those operations allows to extract primitive values out of the [ByteArray] byte buffers. * Data is treated as if it was in Least-Significant-Byte first (little-endian) byte order. - * If index is outside of array boundaries - [ArrayIndexOutOfBoundsException] is thrown. + * If index is outside of array boundaries - [IndexOutOfBoundsException] is thrown. */ /** * Gets [UByte] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @ExperimentalUnsignedTypes public fun ByteArray.getUByteAt(index: Int): UByte = UByte(get(index)) /** * Gets [Char] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getCharAt") public external fun ByteArray.getCharAt(index: Int): Char /** * Gets [Short] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getShortAt") public external fun ByteArray.getShortAt(index: Int): Short /** * Gets [UShort] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getShortAt") @ExperimentalUnsignedTypes @@ -43,14 +43,14 @@ public external fun ByteArray.getUShortAt(index: Int): UShort /** * Gets [Int] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getIntAt") public external fun ByteArray.getIntAt(index: Int): Int /** * Gets [UInt] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getIntAt") @ExperimentalUnsignedTypes @@ -58,14 +58,14 @@ public external fun ByteArray.getUIntAt(index: Int): UInt /** * Gets [Long] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getLongAt") public external fun ByteArray.getLongAt(index: Int): Long /** * Gets [ULong] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getLongAt") @ExperimentalUnsignedTypes @@ -73,42 +73,42 @@ public external fun ByteArray.getULongAt(index: Int): ULong /** * Gets [Float] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getFloatAt") public external fun ByteArray.getFloatAt(index: Int): Float /** * Gets [Double] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_getDoubleAt") public external fun ByteArray.getDoubleAt(index: Int): Double /** * Sets [UByte] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_set") public external fun ByteArray.setUByteAt(index: Int, value: UByte) /** * Sets [Char] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setCharAt") public external fun ByteArray.setCharAt(index: Int, value: Char) /** * Sets [Short] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setShortAt") public external fun ByteArray.setShortAt(index: Int, value: Short) /** * Sets [UShort] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setShortAt") @ExperimentalUnsignedTypes @@ -116,28 +116,28 @@ public external fun ByteArray.setUShortAt(index: Int, value: UShort) /** * Sets [Int] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setIntAt") public external fun ByteArray.setIntAt(index: Int, value: Int) /** * Sets [UInt] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setIntAt") public external fun ByteArray.setUIntAt(index: Int, value: UInt) /** * Sets [Long] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setLongAt") public external fun ByteArray.setLongAt(index: Int, value: Long) /** * Sets [ULong] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setLongAt") @ExperimentalUnsignedTypes @@ -145,14 +145,14 @@ public external fun ByteArray.setULongAt(index: Int, value: ULong) /** * Sets [Float] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setFloatAt") public external fun ByteArray.setFloatAt(index: Int, value: Float) /** * Sets [Double] out of the [ByteArray] byte buffer at specified index [index] - * @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries. + * @throws IndexOutOfBoundsException if [index] is outside of array boundaries. */ @GCUnsafeCall("Kotlin_ByteArray_setDoubleAt") public external fun ByteArray.setDoubleAt(index: Int, value: Double) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index 6aa9c8099ca..6a5716c730e 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -23,6 +23,7 @@ internal fun ThrowIndexOutOfBoundsException(): Nothing { @ExportForCppRuntime internal fun ThrowArrayIndexOutOfBoundsException(): Nothing { + @Suppress("DEPRECATION") throw ArrayIndexOutOfBoundsException() } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt index bd0b8d2a296..7a8a71489a7 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt @@ -334,7 +334,7 @@ public actual fun String(chars: CharArray): String = chars.concatToString() @DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5") public actual fun String(chars: CharArray, offset: Int, length: Int): String { if (offset < 0 || length < 0 || offset + length > chars.size) - throw ArrayIndexOutOfBoundsException() + throw IndexOutOfBoundsException() return unsafeStringFromCharArray(chars, offset, length) }