Use Array constructor with size to create Array of nulls

Change the constructor visibility from public to private as it should be.
This commit is contained in:
Zalim Bashorov
2023-04-20 15:46:30 +02:00
committed by Space Team
parent a6520a294b
commit 77491ded1b
7 changed files with 8 additions and 7 deletions
@@ -14,7 +14,7 @@ import kotlin.wasm.internal.*
* See [Kotlin language documentation](https://kotlinlang.org/docs/reference/basic-types.html#arrays)
* for more information on arrays.
*/
public class Array<T> constructor(size: Int) {
public class Array<T> @PublishedApi internal constructor(size: Int) {
internal val storage: WasmAnyArray = WasmAnyArray(size)
@Suppress("TYPE_PARAMETER_AS_REIFIED", "UNUSED_PARAMETER", "CAST_NEVER_SUCCEEDS")
@@ -28,6 +28,7 @@ public class Array<T> constructor(size: Int) {
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
// TODO: it have to be inline
@Suppress("TYPE_PARAMETER_AS_REIFIED")
public constructor(size: Int, init: (Int) -> T) : this(size) {
storage.fill(size, init)