JS: support callable references with vararg and default parameters conversion

This commit is contained in:
Anton Bannykh
2020-02-20 15:22:01 +03:00
parent f6a23ea441
commit e7816b4ec2
24 changed files with 152 additions and 41 deletions
@@ -0,0 +1,50 @@
// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JVM_IR, JS_IR
// WITH_RUNTIME
import kotlin.test.assertEquals
class C(val expected: Int) {
fun memberVararg(i: Int, vararg s: String) {
assertEquals(expected, i)
assertEquals(0, s.size)
}
fun memberDefault(i: Int, s: String = "") {
assertEquals(expected, i)
assertEquals("", s)
}
fun memberBoth(i: Int, s: String = "", vararg t: String) {
assertEquals(expected, i)
assertEquals("", s)
assertEquals(0, t.size)
}
}
fun C.extensionVararg(i: Int, vararg s: String) {
memberVararg(i, *s)
}
fun C.extensionDefault(i: Int, s: String = "") {
memberDefault(i, s)
}
fun C.extensionBoth(i: Int, s: String = "", vararg t: String) {
memberBoth(i, s, *t)
}
fun test(f: C.(Int) -> Unit, p: Int) = C(p).f(p)
fun box(): String {
test(C::memberVararg, 43)
test(C::memberDefault, 43)
test(C::memberBoth, 43)
test(C::extensionVararg, 43)
test(C::extensionDefault, 43)
test(C::extensionBoth, 43)
return "OK"
}