Fix ArrayStoreException from InlineClassAwareCaller.call

#KT-56650 Fixed
This commit is contained in:
wrongwrong
2023-02-14 16:13:31 +09:00
committed by Alexander Udalov
parent 10e9ef349f
commit b039f2e574
7 changed files with 57 additions and 8 deletions
@@ -125,16 +125,21 @@ internal class InlineClassAwareCaller<out M : Member?>(
val (range, unbox, box) = data
@Suppress("UNCHECKED_CAST")
val unboxed = args.copyOf() as Array<Any?>
for (index in range) {
val method = unbox[index]
val unboxed = Array(args.size) { index ->
val arg = args[index]
// Note that arg may be null in case we're calling a $default method and it's an optional parameter of an inline class type
unboxed[index] = if (method != null) {
if (arg != null) {
method.invoke(arg)
if (index in range) {
// Note that arg may be null in case we're calling a $default method and it's an optional parameter of an inline class type
val method = unbox[index]
if (method != null) {
if (arg != null) {
method.invoke(arg)
} else {
defaultPrimitiveValue(method.returnType)
}
} else {
defaultPrimitiveValue(method.returnType)
arg
}
} else {
arg