From 12f2c04a0bc7758fa5c8c70fa353d0ac17003537 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 21 Dec 2016 15:45:02 +0300 Subject: [PATCH] Misc: Fix argument copying --- .../jetbrains/kotlin/cli/common/arguments/argumentUtils.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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() } -- GitLab