Skip to content

Commit

Permalink
Use ArgumentBucket and SpreadWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Jan 10, 2021
1 parent 34703df commit 1d6198e
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,18 @@ internal class KotlinValueInstantiator(
) {
callable.isAccessible = true
}
val callableParametersByName = linkedMapOf<KParameter, Any?>()
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)
}

}
Expand Down

0 comments on commit 1d6198e

Please sign in to comment.