JVM_IR: Support suspend lambdas with many arguments.
This commit is contained in:
+29
-1
@@ -1,5 +1,5 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR, JS, NATIVE, JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR, JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
// WITH_COROUTINES
|
||||
|
||||
@@ -27,6 +27,20 @@ suspend fun expectsLambdaWithBigArity(c: suspend (Long, Long, Long, Long, Long,
|
||||
return c.invoke(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, "OK")
|
||||
}
|
||||
|
||||
// Uses Function22.invoke with individual arguments. Function22 and not Function21 because of the added continuation parameter.
|
||||
suspend fun expectsLambdaWithArity21(c: suspend (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
|
||||
Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
|
||||
String) -> String): String {
|
||||
return c.invoke(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "OK")
|
||||
}
|
||||
|
||||
// Uses FunctionN.invoke with varargs array of arguments.
|
||||
suspend fun expectsLambdaWithArity22(c: suspend (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
|
||||
Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
|
||||
Int, String) -> String): String {
|
||||
return c.invoke(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "OK")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
var res = "FAIL 1"
|
||||
@@ -43,5 +57,19 @@ fun box(): String {
|
||||
builder {
|
||||
res = expectsLambdaWithBigArity { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, s -> s }
|
||||
}
|
||||
if (res != "OK") return res
|
||||
res = "FAIL 4"
|
||||
builder {
|
||||
res = expectsLambdaWithArity21 {
|
||||
i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, s -> s
|
||||
}
|
||||
}
|
||||
if (res != "OK") return res
|
||||
res = "FAIL 5"
|
||||
builder {
|
||||
res = expectsLambdaWithArity22 {
|
||||
i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, s -> s
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user