[FIR] Fix translation of invokes & add return expressions for lambdas
* fixed NoSuchMethod caused by mismatched signatures of the "invoke" method generated for lambda arguments * added test cases in invoke.kt for KFunction and anonymous functions * added a transformer to wrap the last expression in the bodies of lambdas with return
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5eedba3903
commit
7249d2f889
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
package invoke
|
||||
|
||||
fun test1(predicate: (Int) -> Int, i: Int) = predicate(i)
|
||||
@@ -24,6 +23,9 @@ fun box() : String {
|
||||
if (test2({ it }, 2) != 2) return "fail 2"
|
||||
if (test3(Method(), 3) != 3) return "fail 3"
|
||||
if (test4(Method(), 4) != 4) return "fail 4"
|
||||
if (test5(Method2(), "s") != "s") return "fail5"
|
||||
if (test5(Method2(), "s") != "s") return "fail 5"
|
||||
if (test1(Int::dec, 1) != 0) return "fail 6"
|
||||
if (test2(Int::dec, 1) != 0) return "fail 7"
|
||||
if (test1(fun(x: Int) = x - 1, 1) != 0) return "fail 8"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
//KT-3217 Invoke convention after function invocation doesn't work
|
||||
//KT-2728 Can't compile A()()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
//KT-3189 Function invoke is called with no reason
|
||||
|
||||
fun box(): String {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
//KT-3297 Calling the wrong function inside an extension method to the Function0 class
|
||||
|
||||
infix fun <R> Function0<R>.or(alt: () -> R): R {
|
||||
|
||||
Reference in New Issue
Block a user