diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 7502232b92a..1d1aec1a73f 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -11254,6 +11254,15 @@ public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: return Arrays.binarySearch(this, fromIndex, toIndex, element) } +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@JvmName("mutableCopyOf") +public fun Array.copyOf(): Array { + return Arrays.copyOf(this, size) +} + /** * Returns new array which is a copy of the original array. */ @@ -11323,8 +11332,8 @@ public fun ShortArray.copyOf(): ShortArray { */ @kotlin.jvm.JvmVersion @JvmName("mutableCopyOf") -public fun Array.copyOf(): Array { - return Arrays.copyOf(this, size) +public fun Array.copyOf(newSize: Int): Array { + return Arrays.copyOf(this, newSize) } /** @@ -11392,12 +11401,12 @@ public fun ShortArray.copyOf(newSize: Int): ShortArray { } /** - * Returns new array which is a copy of the original array. + * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -@JvmName("mutableCopyOf") -public fun Array.copyOf(newSize: Int): Array { - return Arrays.copyOf(this, newSize) +@JvmName("mutableCopyOfRange") +public fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array { + return Arrays.copyOfRange(this, fromIndex, toIndex) } /** @@ -11465,12 +11474,11 @@ public fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray { } /** - * Returns new array which is a copy of range of original array. + * Fills original array with the provided value. */ @kotlin.jvm.JvmVersion -@JvmName("mutableCopyOfRange") -public fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array { - return Arrays.copyOfRange(this, fromIndex, toIndex) +public fun Array.fill(element: T, fromIndex: Int = 0, toIndex: Int = size): Unit { + Arrays.fill(this, fromIndex, toIndex, element) } /** @@ -11537,14 +11545,6 @@ public fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = si Arrays.fill(this, fromIndex, toIndex, element) } -/** - * Fills original array with the provided value. - */ -@kotlin.jvm.JvmVersion -public fun Array.fill(element: T, fromIndex: Int = 0, toIndex: Int = size): Unit { - Arrays.fill(this, fromIndex, toIndex, element) -} - /** * Returns a list containing all elements that are instances of specified type parameter R. */ @@ -11579,6 +11579,17 @@ public fun , R> Array<*>.filterIsInstanceTo(destinat return destination } +/** + * Returns an array containing all elements of the original array and then the given [element]. + */ +@kotlin.jvm.JvmVersion +public operator fun Array.plus(element: T): Array { + val index = size + val result = Arrays.copyOf(this, index + 1) + result[index] = element + return result +} + /** * Returns an array containing all elements of the original array and then the given [element]. */ @@ -11668,13 +11679,13 @@ public operator fun ShortArray.plus(element: Short): ShortArray { } /** - * Returns an array containing all elements of the original array and then the given [element]. + * Returns an array containing all elements of the original array and then all elements of the given [elements] collection. */ @kotlin.jvm.JvmVersion -public operator fun Array.plus(element: T): Array { - val index = size - val result = Arrays.copyOf(this, index + 1) - result[index] = element +public operator fun Array.plus(elements: Collection): Array { + var index = size + val result = Arrays.copyOf(this, index + elements.size) + for (element in elements) result[index++] = element return result } @@ -11767,13 +11778,14 @@ public operator fun ShortArray.plus(elements: Collection): ShortArray { } /** - * Returns an array containing all elements of the original array and then all elements of the given [elements] collection. + * Returns an array containing all elements of the original array and then all elements of the given [elements] array. */ @kotlin.jvm.JvmVersion -public operator fun Array.plus(elements: Collection): Array { - var index = size - val result = Arrays.copyOf(this, index + elements.size) - for (element in elements) result[index++] = element +public operator fun Array.plus(elements: Array): Array { + val thisSize = size + val arraySize = elements.size + val result = Arrays.copyOf(this, thisSize + arraySize) + System.arraycopy(elements, 0, result, thisSize, arraySize) return result } @@ -11873,18 +11885,6 @@ public operator fun ShortArray.plus(elements: ShortArray): ShortArray { return result } -/** - * Returns an array containing all elements of the original array and then all elements of the given [elements] array. - */ -@kotlin.jvm.JvmVersion -public operator fun Array.plus(elements: Array): Array { - val thisSize = size - val arraySize = elements.size - val result = Arrays.copyOf(this, thisSize + arraySize) - System.arraycopy(elements, 0, result, thisSize, arraySize) - return result -} - /** * Sorts the array in-place. */ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt index cf43caec293..20d27a31e22 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt @@ -12,9 +12,9 @@ enum class Family { Lists, Maps, Sets, + InvariantArraysOfObjects, ArraysOfObjects, ArraysOfPrimitives, - InvariantArraysOfObjects, CharSequences, Strings, Ranges, @@ -175,7 +175,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") { fun instantiate(vararg families: Family = Family.values()): List { return families - .sortedBy { it.name } + .sortedBy { if (it == InvariantArraysOfObjects) "ArraysOfObjectsInvariant" else it.name } .filter { buildFamilies.contains(it) } .flatMap { family -> instantiate(family) } }