// IGNORE_BACKEND: WASM // WASM_MUTE_REASON: JAVA // WITH_STDLIB // FULL_JDK // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS fun Any.copyValueIfNeeded(): Any { return when (this) { is Array<*> -> java.lang.reflect.Array.newInstance(this::class.java.componentType, size).apply { this as Array (this@copyValueIfNeeded as Array).forEachIndexed { i, value -> this[i] = value?.copyValueIfNeeded() } } else -> this } } fun box(): String { val res = arrayOf("FAIL", "OK").copyValueIfNeeded() as Array return res[1] }