[Wasm] Fix overloading virtual methods by vararg and array element type
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
This commit is contained in:
committed by
Space Team
parent
b5def88ff4
commit
76e132e758
@@ -0,0 +1,35 @@
|
||||
// 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"
|
||||
}
|
||||
Reference in New Issue
Block a user