Improve argument validation in copyOfRange
Make copyOfRange implementation non-inline in order not to expose copyOfRangeToIndexCheck implementation detail. It will be possible to make the function non-inline itself later without that JvmName trick, when apiVersion 1.2 support is discontinued. #KT-19489
This commit is contained in:
@@ -5737,48 +5737,75 @@ public expect fun CharArray.copyOf(newSize: Int): CharArray
|
||||
public expect fun <T> Array<T>.copyOf(newSize: Int): Array<T?>
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
@Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
public expect fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
* Returns a new array which is a copy of the specified range of the original array.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
|
||||
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
|
||||
*/
|
||||
public expect fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray
|
||||
|
||||
|
||||
Reference in New Issue
Block a user