From 1be0e3f70e8f1bac8836193f7cadcdac266844ed Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Sat, 17 Jun 2023 09:50:12 +0300 Subject: [PATCH] Document that arrayOfNulls throws RuntimeException on negative size --- core/builtins/native/kotlin/Library.kt | 2 ++ kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt | 2 ++ libraries/stdlib/wasm/builtins/kotlin/Library.kt | 2 ++ 3 files changed, 6 insertions(+) diff --git a/core/builtins/native/kotlin/Library.kt b/core/builtins/native/kotlin/Library.kt index fe279a1ec52..db55a0f204d 100644 --- a/core/builtins/native/kotlin/Library.kt +++ b/core/builtins/native/kotlin/Library.kt @@ -32,6 +32,8 @@ 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. + * + * @throws RuntimeException if the specified [size] is negative. */ public fun arrayOfNulls(size: Int): Array diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt index 2fab2f3975e..8057d8fd3a5 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt @@ -585,6 +585,8 @@ private class BooleanIteratorImpl(val collection: BooleanArray) : BooleanIterato /** * Returns an array of objects of the given type with the given [size], initialized with null values. + * + * @throws RuntimeException if the specified [size] is negative. */ public inline fun arrayOfNulls(size: Int): Array = @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") diff --git a/libraries/stdlib/wasm/builtins/kotlin/Library.kt b/libraries/stdlib/wasm/builtins/kotlin/Library.kt index 11715166199..451c0052919 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Library.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Library.kt @@ -27,6 +27,8 @@ public operator fun String?.plus(other: Any?): String = (this ?: "null") + other /** * Returns an array of objects of the given type with the given [size], initialized with null values. + * + * @throws RuntimeException if the specified [size] is negative. */ // TODO: Should T be reified? @Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")