Add documentation for Array and String get() function behavior

These docs are already added to big kotlin.
This commit is contained in:
Abduqodiri Qurbonzoda
2019-03-18 18:58:37 +03:00
committed by Nikolay Igotti
parent 613084ad9b
commit b654e84ca1
4 changed files with 93 additions and 2 deletions
+6 -2
View File
@@ -45,10 +45,12 @@ public final class Array<T> {
/**
* Returns the array element at the specified [index]. This method can be called using the
* index operator:
* index operator.
* ```
* value = arr[index]
* ```
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_Array_get")
@PointsTo(0b0100, 0, 0b0001) // <this> points to <return>, <return> points to <this>.
@@ -56,10 +58,12 @@ public final class Array<T> {
/**
* Sets the array element at the specified [index] to the specified [value]. This method can
* be called using the index operator:
* be called using the index operator.
* ```
* arr[index] = value
* ```
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_Array_set")
@PointsTo(0b0100, 0, 0b0001) // <this> points to <value>, <value> points to <this>.
+80
View File
@@ -35,9 +35,19 @@ public final class ByteArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_ByteArray_get")
external public operator fun get(index: Int): Byte
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_ByteArray_set")
external public operator fun set(index: Int, value: Byte): Unit
@@ -87,9 +97,19 @@ public final class CharArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_CharArray_get")
external public operator fun get(index: Int): Char
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_CharArray_set")
external public operator fun set(index: Int, value: Char): Unit
@@ -139,9 +159,19 @@ public final class ShortArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_ShortArray_get")
external public operator fun get(index: Int): Short
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_ShortArray_set")
external public operator fun set(index: Int, value: Short): Unit
@@ -191,9 +221,19 @@ public final class IntArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_IntArray_get")
external public operator fun get(index: Int): Int
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_IntArray_set")
external public operator fun set(index: Int, value: Int): Unit
@@ -243,9 +283,19 @@ public final class LongArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_LongArray_get")
external public operator fun get(index: Int): Long
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_LongArray_set")
external public operator fun set(index: Int, value: Long): Unit
@@ -295,9 +345,19 @@ public final class FloatArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_FloatArray_get")
external public operator fun get(index: Int): Float
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_FloatArray_set")
external public operator fun set(index: Int, value: Float): Unit
@@ -343,9 +403,19 @@ public final class DoubleArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_DoubleArray_get")
external public operator fun get(index: Int): Double
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_DoubleArray_set")
external public operator fun set(index: Int, value: Double): Unit
@@ -391,9 +461,19 @@ public final class BooleanArray {
public val size: Int
get() = getArrayLength()
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_BooleanArray_get")
external public operator fun get(index: Int): Boolean
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_BooleanArray_set")
external public operator fun set(index: Int, value: Boolean): Unit
@@ -16,6 +16,8 @@ public interface CharSequence {
/**
* Returns the character at the specified [index] in this character sequence.
*
* @throws [IndexOutOfBoundsException] if the [index] is out of bounds of this character sequence.
*/
public operator fun get(index: Int): Char
+5
View File
@@ -28,6 +28,11 @@ public final class String : Comparable<String>, CharSequence {
public override val length: Int
get() = getStringLength()
/**
* Returns the character of this string at the specified [index].
*
* If the [index] is out of bounds of this string, throws an [IndexOutOfBoundsException].
*/
@SymbolName("Kotlin_String_get")
external override public fun get(index: Int): Char