[JS IR BE] Fix Callable reference with vararg

* Update tests
This commit is contained in:
Roman Artemev
2019-03-14 20:53:34 +03:00
committed by romanart
parent a2d65e8a60
commit 1f98eaa27b
2 changed files with 27 additions and 9 deletions
@@ -1,7 +1,9 @@
// !LANGUAGE: +NewInference
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JVM_IR, JS
fun call(f: (String, String) -> String, x: String, y: String): String = f(x, y)
fun call0(f: (String) -> String, x: String): String = f(x)
fun call1(f: (String, String) -> String, x: String, y: String): String = f(x, y)
fun call2(f: (String, String, String) -> String, x: String, y: String, z: String): String = f(x, y, z)
fun box(): String {
@@ -9,7 +11,21 @@ fun box(): String {
fun foo(x: String, y: String = "5", z: String = "4"): String = s + x + y + z
val r = call(::foo, "2", "3")
val r = call1(::foo, "2", "3")
if (r != "1234") return "FAIL $r"
fun bar(x: String, vararg y: CharSequence = arrayOf("2")): String = s + x + y.size + y[0]
s = "5"
val r0 = call0(::bar, "3")
if (r0 != "5312") return "FAIL1 $r0"
s = "6"
val r2 = call1(::bar, "2", "5")
if (r2 != "6215") return "FAIL2 $r2"
s = "7"
val r3 = call2(::bar, "8", "9", "10")
if (r3 != "7829") return "FAIL3 $r3"
return "OK"
}
@@ -1,13 +1,15 @@
// !LANGUAGE: +NewInference
// IGNORE_BACKEND: JS, JVM_IR
fun foo(x: Int, vararg y: String = arrayOf("Aaa")): String =
if (y[0].length == x) "OK" else "Fail"
fun foo(x: Int, s: Int, vararg y: CharSequence = arrayOf("Aaa")): String =
if (y.size == s && y[0].length == x) "OK" else "Fail"
fun use0(f: (Int) -> String): String = f(3)
fun use1(f: (Int, String) -> String): String = f(5, "Bbbbb")
fun use0(f: (Int, Int) -> String): String = f(3, 1)
fun use1(f: (Int, Int, String) -> String): String = f(5, 1, "Bbbbb")
fun use2(f: (Int, Int, String, String) -> String): String = f(5, 2, "Bbbbb", "Ccccc")
fun box(): String {
if (use0(::foo) != "OK") return "Fail"
return use1(::foo)
if (use0(::foo) != "OK") return "Fail0"
if (use1(::foo) != "OK") return "Fail1"
return use2(::foo)
}