76e132e758
Context: - Kotlin allows functions overloaded with different array element types. - Varargs are lowered to Array parameters. - Before this commit, K/Wasm erased an array element type from the signature, similar to type argument erasure in other cases. Fix: Stop erasing type arguments in arrays when computing v-table signatures. ^KT-58852 Fixed
35 lines
930 B
Kotlin
Vendored
35 lines
930 B
Kotlin
Vendored
// WITH_REFLECT
|
|
|
|
// Simplified original example from KT-58825
|
|
|
|
import kotlin.reflect.*
|
|
|
|
interface DynamicShapeRegister<T> {
|
|
fun register(vararg items: KProperty<*>) {}
|
|
fun register(vararg items: KCallable<*>) {}
|
|
}
|
|
|
|
class C : DynamicShapeRegister<Int>
|
|
val p: Int = 0
|
|
|
|
// Additional tests with nested arrays
|
|
|
|
interface ArrayDimensions {
|
|
fun getD(x: Array<Int>): String = "1D"
|
|
fun getD(x: Array<Array<Int>>): String = "2D"
|
|
fun getD(x: Array<Array<Array<Int>>>): String = "3D"
|
|
fun getD(x: Array<Array<Array<Array<Int>>>>): String = "4D"
|
|
}
|
|
|
|
fun box(): String {
|
|
C().register(::p, ::p)
|
|
C().register(::box, ::box, ::C)
|
|
|
|
val ad: ArrayDimensions = object : ArrayDimensions {}
|
|
check("1D" == ad.getD(arrayOf(1)))
|
|
check("2D" == ad.getD(arrayOf(arrayOf(1))))
|
|
check("3D" == ad.getD(arrayOf(arrayOf(arrayOf(1)))))
|
|
check("4D" == ad.getD(arrayOf(arrayOf(arrayOf(arrayOf(1))))))
|
|
|
|
return "OK"
|
|
} |