[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:
Juan Chen
2020-02-01 18:18:03 -08:00
committed by Mikhail Glukhikh
parent 5eedba3903
commit 7249d2f889
194 changed files with 397 additions and 506 deletions
@@ -29,4 +29,5 @@ FILE fqName:<root> fileName:/basicFunInterfaceConversion.kt
f: FUN_EXPR type=kotlin.Function0<kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
CONST String type=kotlin.String value="OK"
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.test'
CONST String type=kotlin.String value="OK"
@@ -115,7 +115,8 @@ FILE fqName:<root> fileName:/partialSam.kt
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:ti index:2 type:kotlin.Int
BLOCK_BODY
CONST String type=kotlin.String value=""
RETURN type=kotlin.Nothing from='local final fun <anonymous> (s: kotlin.String, i: kotlin.Int, ti: kotlin.Int): kotlin.String declared in <root>.test'
CONST String type=kotlin.String value=""
CALL 'public final fun runConversion (f1: <root>.Fn<kotlin.String, kotlin.Int>, f2: <root>.Fn<kotlin.Int, kotlin.String>): kotlin.Int declared in <root>.J' type=kotlin.Int origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
f1: FUN_EXPR type=kotlin.Function3<kotlin.String, kotlin.Int, kotlin.String, kotlin.Int> origin=LAMBDA
@@ -124,5 +125,6 @@ FILE fqName:<root> fileName:/partialSam.kt
VALUE_PARAMETER name:i index:1 type:kotlin.Int
VALUE_PARAMETER name:ts index:2 type:kotlin.String
BLOCK_BODY
CONST Int type=kotlin.Int value=1
RETURN type=kotlin.Nothing from='local final fun <anonymous> (s: kotlin.String, i: kotlin.Int, ts: kotlin.String): kotlin.Int declared in <root>.test'
CONST Int type=kotlin.Int value=1
f2: CALL 'public final fun <get-fis> (): <uninitialized parent>.<anonymous> declared in <root>' type=<uninitialized parent>.<anonymous> origin=null