Do not require array extensions being reified to create new array.

#KT-15377
This commit is contained in:
Ilya Gorbunov
2016-12-23 20:25:17 +03:00
parent 510295475b
commit 05dcaccf09
5 changed files with 12 additions and 5 deletions
+4 -1
View File
@@ -18,8 +18,11 @@ package kotlin.collections
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")
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")
internal fun <T> copyToArray(collection: Collection<T>): Array<T> {
+1 -1
View File
@@ -19,7 +19,7 @@ package kotlin
/**
* 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
public fun <T> arrayOf(vararg elements: T): Array<T> = noImpl