Remove reified constraint from Array constructors #KT-57363
This is an attempt to bring consistency to array constructors reified requirement. Currently, JVM - reified type in all three: arrayOfNulls, arrayOf, emptyArray Native - reified in arrayOfNulls and arrayOf, but not in emptyArray JS & Wasm - reified in arrayOfNulls, but not in arrayOf and emptyArray Merge-request: KT-MR-11005 Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
2a24eaeb74
commit
86c1e0ded6
@@ -8,7 +8,6 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.PureReifiable
|
||||
import kotlin.native.internal.ExportTypeInfo
|
||||
import kotlin.native.internal.IntrinsicType
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
@@ -588,7 +587,7 @@ private class BooleanIteratorImpl(val collection: BooleanArray) : BooleanIterato
|
||||
*
|
||||
* @throws RuntimeException if the specified [size] is negative.
|
||||
*/
|
||||
public inline fun <reified @PureReifiable T> arrayOfNulls(size: Int): Array<T?> =
|
||||
public inline fun <T> arrayOfNulls(size: Int): Array<T?> =
|
||||
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
arrayOfUninitializedElements<T?>(size)
|
||||
|
||||
@@ -597,7 +596,7 @@ public inline fun <reified @PureReifiable T> arrayOfNulls(size: Int): Array<T?>
|
||||
*/
|
||||
@TypedIntrinsic(IntrinsicType.IDENTITY)
|
||||
@PointsTo(0x00, 0x01) // ret -> elements
|
||||
public external inline fun <reified @PureReifiable T> arrayOf(vararg elements: T): Array<T>
|
||||
public external inline fun <T> arrayOf(vararg elements: T): Array<T>
|
||||
|
||||
@GCUnsafeCall("Kotlin_emptyArray")
|
||||
external public fun <T> emptyArray(): Array<T>
|
||||
|
||||
@@ -45,7 +45,7 @@ public inline fun UShortArray(size: kotlin.Int, init: (kotlin.Int) -> kotlin.USh
|
||||
|
||||
public inline fun <T> arrayOf(vararg elements: T): kotlin.Array<T>
|
||||
|
||||
public inline fun <reified T> arrayOfNulls(size: kotlin.Int): kotlin.Array<T?>
|
||||
public inline fun <T> arrayOfNulls(size: kotlin.Int): kotlin.Array<T?>
|
||||
|
||||
public inline fun booleanArrayOf(vararg elements: kotlin.Boolean): kotlin.BooleanArray
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.PureReifiable
|
||||
import kotlin.js.*
|
||||
|
||||
/**
|
||||
@@ -27,7 +26,7 @@ public operator fun String?.plus(other: Any?): String =
|
||||
/**
|
||||
* Returns an array of objects of the given type with the given [size], initialized with null values.
|
||||
*/
|
||||
public inline fun <reified T> arrayOfNulls(size: Int): Array<T?> = fillArrayVal<T?>(Array<T?>(size), null)
|
||||
public inline fun <T> arrayOfNulls(size: Int): Array<T?> = fillArrayVal<T?>(Array<T?>(size), null)
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified elements.
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.PureReifiable
|
||||
import kotlin.wasm.internal.enumValueOfIntrinsic
|
||||
import kotlin.wasm.internal.enumValuesIntrinsic
|
||||
|
||||
@@ -30,9 +29,8 @@ public operator fun String?.plus(other: Any?): String = (this ?: "null") + other
|
||||
*
|
||||
* @throws RuntimeException if the specified [size] is negative.
|
||||
*/
|
||||
// TODO: Should T be reified?
|
||||
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")
|
||||
public fun <@PureReifiable reified T> arrayOfNulls(size: Int): Array<T?> = Array(size)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
public inline fun <T> arrayOfNulls(size: Int): Array<T?> = Array<Any?>(size) as Array<T?>
|
||||
|
||||
/**
|
||||
* Returns an array containing the specified elements.
|
||||
|
||||
Reference in New Issue
Block a user