Do not require array extensions being reified to create new array.
#KT-15377
This commit is contained in:
@@ -18,8 +18,11 @@ package kotlin.collections
|
|||||||
|
|
||||||
import kotlin.comparisons.naturalOrder
|
import kotlin.comparisons.naturalOrder
|
||||||
|
|
||||||
|
/** Returns the array if it's not `null`, or an empty array otherwise. */
|
||||||
|
public inline fun <T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
|
||||||
|
|
||||||
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||||
public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> = copyToArray(this)
|
public inline fun <T> Collection<T>.toTypedArray(): Array<T> = copyToArray(this)
|
||||||
|
|
||||||
@JsName("copyToArray")
|
@JsName("copyToArray")
|
||||||
internal fun <T> copyToArray(collection: Collection<T>): Array<T> {
|
internal fun <T> copyToArray(collection: Collection<T>): Array<T> {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package kotlin
|
|||||||
/**
|
/**
|
||||||
* Returns an empty array of the specified type [T].
|
* Returns an empty array of the specified type [T].
|
||||||
*/
|
*/
|
||||||
public inline fun <reified T> emptyArray(): Array<T> = js("[]")
|
public inline fun <T> emptyArray(): Array<T> = js("[]")
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun <T> arrayOf(vararg elements: T): Array<T> = noImpl
|
public fun <T> arrayOf(vararg elements: T): Array<T> = noImpl
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ header abstract class AbstractMutableList<E> : MutableList<E> {
|
|||||||
|
|
||||||
// From collections.kt
|
// From collections.kt
|
||||||
|
|
||||||
|
/** Returns the array if it's not `null`, or an empty array otherwise. */
|
||||||
|
header inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
|
||||||
|
|
||||||
|
|
||||||
header inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
|
header inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
|
||||||
|
|
||||||
header fun <T : Comparable<T>> MutableList<T>.sort(): Unit
|
header fun <T : Comparable<T>> MutableList<T>.sort(): Unit
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
package kotlin.collections
|
package kotlin.collections
|
||||||
|
|
||||||
|
|
||||||
/** Returns the array if it's not `null`, or an empty array otherwise. */
|
|
||||||
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single list of all elements from all arrays in the given array.
|
* Returns a single list of all elements from all arrays in the given array.
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ package kotlin.collections
|
|||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
|
|
||||||
|
/** Returns the array if it's not `null`, or an empty array otherwise. */
|
||||||
|
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the contents of this byte array to a string using the specified [charset].
|
* Converts the contents of this byte array to a string using the specified [charset].
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user