Check for index-out-of-bound in elementAt function (KT-30051)
This commit is contained in:
@@ -443,90 +443,63 @@ public operator fun CharArray.contains(element: Char): Boolean {
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.elementAt(index: Int): T {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun <T> Array<out T>.elementAt(index: Int): T
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.elementAt(index: Int): Byte {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun ByteArray.elementAt(index: Int): Byte
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.elementAt(index: Int): Short {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun ShortArray.elementAt(index: Int): Short
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.elementAt(index: Int): Int {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun IntArray.elementAt(index: Int): Int
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.elementAt(index: Int): Long {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun LongArray.elementAt(index: Int): Long
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.elementAt(index: Int): Float {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun FloatArray.elementAt(index: Int): Float
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.elementAt(index: Int): Double {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun DoubleArray.elementAt(index: Int): Double
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.elementAt(index: Int): Boolean {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun BooleanArray.elementAt(index: Int): Boolean
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.elementAt(index: Int): Char {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun CharArray.elementAt(index: Int): Char
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
|
||||
|
||||
@@ -20,10 +20,7 @@ import kotlin.random.*
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.elementAt(index: Int): Char {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun CharSequence.elementAt(index: Int): Char
|
||||
|
||||
/**
|
||||
* Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence.
|
||||
|
||||
@@ -223,10 +223,7 @@ public inline operator fun UShortArray.component5(): UShort {
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.elementAt(index: Int): UInt {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun UIntArray.elementAt(index: Int): UInt
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
@@ -235,10 +232,7 @@ public inline fun UIntArray.elementAt(index: Int): UInt {
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.elementAt(index: Int): ULong {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun ULongArray.elementAt(index: Int): ULong
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
@@ -247,10 +241,7 @@ public inline fun ULongArray.elementAt(index: Int): ULong {
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.elementAt(index: Int): UByte {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun UByteArray.elementAt(index: Int): UByte
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
@@ -259,10 +250,7 @@ public inline fun UByteArray.elementAt(index: Int): UByte {
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.elementAt(index: Int): UShort {
|
||||
return get(index)
|
||||
}
|
||||
public expect fun UShortArray.elementAt(index: Int): UShort
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
|
||||
|
||||
Reference in New Issue
Block a user