diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/argumentUtils.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/argumentUtils.kt index a13a703c27f..8a4c743bc5c 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/argumentUtils.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/argumentUtils.kt @@ -50,7 +50,10 @@ private fun Any.copyValueIfNeeded(): Any { is DoubleArray -> Arrays.copyOf(this, size) is BooleanArray -> Arrays.copyOf(this, size) - is Array<*> -> Array(size) { this[it]?.copyValueIfNeeded() } + is Array<*> -> java.lang.reflect.Array.newInstance(javaClass.componentType, size).apply { + this as Array + (this@copyValueIfNeeded as Array).forEachIndexed { i, value -> this[i] = value?.copyValueIfNeeded() } + } is MutableCollection<*> -> (this as Collection).mapTo(javaClass.newInstance() as MutableCollection) { it?.copyValueIfNeeded() }