[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
@@ -36,10 +36,11 @@ FILE fqName:<root> fileName:/withVarargViewedAsArray.kt
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int
VALUE_PARAMETER name:it index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public abstract fun toInt (): kotlin.Int declared in kotlin.Number' type=kotlin.Int origin=null
$this: CALL 'public final fun get (index: kotlin.Int): kotlin.Number [operator] declared in kotlin.Array' type=kotlin.Number origin=null
$this: GET_VAR 'args: kotlin.Array<kotlin.Number> [vararg] declared in <root>.nsum' type=kotlin.Array<kotlin.Number> origin=null
index: GET_VAR 'it: kotlin.Int declared in <root>.nsum.<anonymous>' type=kotlin.Int origin=null
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.Int): kotlin.Int declared in <root>.nsum'
CALL 'public abstract fun toInt (): kotlin.Int declared in kotlin.Number' type=kotlin.Int origin=null
$this: CALL 'public final fun get (index: kotlin.Int): kotlin.Number [operator] declared in kotlin.Array' type=kotlin.Number origin=null
$this: GET_VAR 'args: kotlin.Array<kotlin.Number> [vararg] declared in <root>.nsum' type=kotlin.Array<kotlin.Number> origin=null
index: GET_VAR 'it: kotlin.Int declared in <root>.nsum.<anonymous>' type=kotlin.Int origin=null
FUN name:zap visibility:public modality:FINAL <> (b:kotlin.Array<kotlin.String>, k:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER name:b index:0 type:kotlin.Array<kotlin.String> varargElementType:kotlin.String [vararg]
VALUE_PARAMETER name:k index:1 type:kotlin.Int