Remove workaround for complex default value in Array.copyInto
#KT-22818
This commit is contained in:
@@ -5797,7 +5797,7 @@ public expect fun CharArray.contentToString(): String
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): Array<T>
|
||||
public expect fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array<T>
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5816,7 +5816,7 @@ public expect fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOf
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): ByteArray
|
||||
public expect fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5835,7 +5835,7 @@ public expect fun ByteArray.copyInto(destination: ByteArray, destinationOffset:
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): ShortArray
|
||||
public expect fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5854,7 +5854,7 @@ public expect fun ShortArray.copyInto(destination: ShortArray, destinationOffset
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): IntArray
|
||||
public expect fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5873,7 +5873,7 @@ public expect fun IntArray.copyInto(destination: IntArray, destinationOffset: In
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): LongArray
|
||||
public expect fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5892,7 +5892,7 @@ public expect fun LongArray.copyInto(destination: LongArray, destinationOffset:
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): FloatArray
|
||||
public expect fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5911,7 +5911,7 @@ public expect fun FloatArray.copyInto(destination: FloatArray, destinationOffset
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): DoubleArray
|
||||
public expect fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5930,7 +5930,7 @@ public expect fun DoubleArray.copyInto(destination: DoubleArray, destinationOffs
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): BooleanArray
|
||||
public expect fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray
|
||||
|
||||
/**
|
||||
* Copies this array or its subrange into the [destination] array and returns that array.
|
||||
@@ -5949,7 +5949,7 @@ public expect fun BooleanArray.copyInto(destination: BooleanArray, destinationOf
|
||||
* @return the [destination] array.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): CharArray
|
||||
public expect fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
|
||||
@@ -345,7 +345,7 @@ public fun UShortArray.contentToString(): String {
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.copyInto(destination: UIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): UIntArray {
|
||||
public inline fun UIntArray.copyInto(destination: UIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UIntArray {
|
||||
return UIntArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ public inline fun UIntArray.copyInto(destination: UIntArray, destinationOffset:
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.copyInto(destination: ULongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): ULongArray {
|
||||
public inline fun ULongArray.copyInto(destination: ULongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ULongArray {
|
||||
return ULongArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public inline fun ULongArray.copyInto(destination: ULongArray, destinationOffset
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.copyInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): UByteArray {
|
||||
public inline fun UByteArray.copyInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UByteArray {
|
||||
return UByteArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public inline fun UByteArray.copyInto(destination: UByteArray, destinationOffset
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.copyInto(destination: UShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1): UShortArray {
|
||||
public inline fun UShortArray.copyInto(destination: UShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UShortArray {
|
||||
return UShortArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,6 @@ internal actual fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T> {
|
||||
@PublishedApi
|
||||
@JsName("arrayCopy")
|
||||
internal fun <T> arrayCopy(source: Array<out T>, destination: Array<in T>, destinationOffset: Int, startIndex: Int, endIndex: Int) {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) source.size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, source.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
|
||||
@@ -628,8 +628,6 @@ public actual inline fun CharArray.contentToString(): String {
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array<T> {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -653,8 +651,6 @@ public actual fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOf
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -678,8 +674,6 @@ public actual fun ByteArray.copyInto(destination: ByteArray, destinationOffset:
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -703,8 +697,6 @@ public actual fun ShortArray.copyInto(destination: ShortArray, destinationOffset
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -728,8 +720,6 @@ public actual fun IntArray.copyInto(destination: IntArray, destinationOffset: In
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -753,8 +743,6 @@ public actual fun LongArray.copyInto(destination: LongArray, destinationOffset:
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -778,8 +766,6 @@ public actual fun FloatArray.copyInto(destination: FloatArray, destinationOffset
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -803,8 +789,6 @@ public actual fun DoubleArray.copyInto(destination: DoubleArray, destinationOffs
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
@@ -828,8 +812,6 @@ public actual fun BooleanArray.copyInto(destination: BooleanArray, destinationOf
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ class ArraysTest {
|
||||
dest.copyInto(dest, 1, 0, 2)
|
||||
assertTEquals(result3, dest, "Overlapping forward copy: ${result2.toStringT()}, ${dest.toStringT()}")
|
||||
|
||||
for ((start, end) in listOf(-1 to 0, 0 to 4, 4 to 4, 1 to 0)) {
|
||||
for ((start, end) in listOf(-1 to 0, 0 to 4, 4 to 4, 1 to 0, 0 to -1)) {
|
||||
val bounds = "start: $start, end: $end"
|
||||
val ex = assertFails(bounds) { newValues.copyInto(dest, 0, start, end) }
|
||||
assertTrue(ex is IllegalArgumentException || ex is IndexOutOfBoundsException, "Unexpected exception type: $ex")
|
||||
|
||||
@@ -489,8 +489,7 @@ object ArrayOps : TemplateGroupBase() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove -1 from common signature
|
||||
val f_copyInto = fn("copyInto(destination: SELF, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = -1)") {
|
||||
val f_copyInto = fn("copyInto(destination: SELF, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size)") {
|
||||
include(InvariantArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned)
|
||||
} builder {
|
||||
since("1.3")
|
||||
@@ -530,8 +529,6 @@ object ArrayOps : TemplateGroupBase() {
|
||||
signature("copyInto(destination: SELF, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size)")
|
||||
body {
|
||||
"""
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
|
||||
System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
return destination
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user