Don't blow up if a param is anonymous e.g. underscore. (#2020)

This commit is contained in:
Andrzej Cichocki 2017-11-10 15:19:41 +00:00 committed by GitHub
parent 83857950fe
commit 001cb4f901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,14 +26,15 @@ private fun <R> measure(paramIterables: List<Iterable<Any?>>, kCallable: KCallab
val kParameters = kCallable.parameters
return iterateLexical(paramIterables).map { params ->
MeasureResult(
parameters = params.mapIndexed { index, param -> Pair(kParameters[index].name!!, param) },
// For example an underscore param in a lambda does not have a name:
parameters = params.mapIndexed { index, param -> Pair(kParameters[index].name, param) },
result = call(params.toTypedArray())
)
}
}
data class MeasureResult<out R>(
val parameters: List<Pair<String, Any?>>,
val parameters: List<Pair<String?, Any?>>,
val result: R
)