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 11, 2021
1 parent 25b3c79 commit 18ed9b2
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 18ed9b2

Please sign in to comment.