Files
kotlin-fork/compiler/testData/codegen/box/reflection/callBy/mfvcKt61304.kt
T
Alexander Udalov 34f52aaeda Reflection: fix callBy for functions with 32 * N parameters
Optimization in 2439c22ff6 introduced an array `absentArguments` with
default values of all parameter types, which is copied in `callBy`
instead of being recomputed each time. Unfortunately, its size was
computed incorrectly: `maskSize` should only take into account
value parameters (see the `parameter.kind == KParameter.Kind.VALUE`
check in `callBy`).

This led to an issue where if the function had 32 * N value parameters
and 1 receiver parameter, `maskSize` was greater by 1 than expected,
which caused an exception due to mismatching argument array sizes.

 #KT-61304 Fixed
2023-09-05 11:05:29 +00:00

37 lines
844 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// WITH_REFLECT
// LANGUAGE: +ValueClasses
import kotlin.reflect.full.instanceParameter
import kotlin.reflect.full.memberFunctions
@JvmInline
value class S2(val x: Int, val y: Int)
@JvmInline
value class S4(val x: S2, val y: S2)
@JvmInline
value class S8(val x: S4, val y: S4)
@JvmInline
value class S16(val x: S8, val y: S8)
@JvmInline
value class S32(val x: S16, val y: S16)
@JvmInline
value class S64(val x: S32, val y: S32)
data class D(val s: S64 = createS64())
fun createS64(): S64 {
val s2 = S2(0, 0)
val s4 = S4(s2, s2)
val s8 = S8(s4, s4)
val s16 = S16(s8, s8)
val s32 = S32(s16, s16)
return S64(s32, s32)
}
fun box(): String {
val copyFun = D::class.memberFunctions.single { it.name == "copy" }
copyFun.callBy(mapOf(copyFun.instanceParameter!! to D()))
return "OK"
}