From 1d6198e99f81712a9885855d179e0b33b2b60dde Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 9 Jan 2021 13:09:34 +0900 Subject: [PATCH] Use ArgumentBucket and SpreadWrapper --- .../module/kotlin/KotlinValueInstantiator.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinValueInstantiator.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinValueInstantiator.kt index ee55e9494..27e80018e 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinValueInstantiator.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinValueInstantiator.kt @@ -162,13 +162,18 @@ internal class KotlinValueInstantiator( ) { callable.isAccessible = true } - val callableParametersByName = linkedMapOf() - callableParameters.mapIndexed { idx, paramDef -> - if (paramDef != null) { - callableParametersByName[paramDef] = jsonParamValueList[idx] + ArgumentBucket(callable.parameters).apply { + callableParameters.forEachIndexed { idx, paramDef -> + if (paramDef != null) { + this[paramDef] = jsonParamValueList[idx] + } } + }.let { + if (it.isFullInitialized()) + SpreadWrapper.call(callable, it.valueArray) + else + callable.callBy(it) } - callable.callBy(callableParametersByName) } }