Fix exception on callBy of callable with more than 32 parameters

The previous condition that checked if we'd skipped any optional
parameters didn't work when number of parameters > 32 because the number
of bit masks in that case was more than one

 #KT-18404 Fixed
This commit is contained in:
Alexander Udalov
2017-06-19 16:44:05 +03:00
parent 62cd57b0d2
commit 90f2ea87a6
7 changed files with 262 additions and 1 deletions
@@ -118,6 +118,7 @@ internal abstract class KCallableImpl<out R> : KCallable<R> {
var mask = 0
val masks = ArrayList<Int>(1)
var index = 0
var anyOptional = false
for (parameter in parameters) {
if (index != 0 && index % Integer.SIZE == 0) {
@@ -132,6 +133,7 @@ internal abstract class KCallableImpl<out R> : KCallable<R> {
parameter.isOptional -> {
arguments.add(defaultPrimitiveValue(parameter.type.javaType))
mask = mask or (1 shl (index % Integer.SIZE))
anyOptional = true
}
else -> {
throw IllegalArgumentException("No argument provided for a required parameter: $parameter")
@@ -143,7 +145,7 @@ internal abstract class KCallableImpl<out R> : KCallable<R> {
}
}
if (mask == 0 && masks.isEmpty()) {
if (!anyOptional) {
return call(*arguments.toTypedArray())
}