Files
kotlin/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/inline.kt
Ilmir Usmanov f507a26a12 Generate decomposed lambda params in suspend lambda's local variables
Unlike ordinary lambdas, suspend lambdas do the computation in
doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
method. As you can see, there are no decomposed parameters. As a result,
they used not to be generated.
To fix the issue, I add decomposed parameters to value parameters while
generating local variables table.

In addition, when generating suspend lambda for inline, the codegen
does not take this kind of parameters into account. This is also fixed.

 #KT-18576: Fixed
2018-05-03 10:35:13 +03:00

16 lines
761 B
Kotlin
Vendored

data class A(val x: String, val y: String)
suspend inline fun foo(a: A, block: suspend (A) -> String): String = block(a)
suspend fun test() = foo(A("O", "K")) { (x_param, y_param) -> x_param + y_param }
// METHOD : InlineKt.test(Lkotlin/coroutines/experimental/Continuation;)Ljava/lang/Object;
// VARIABLE : NAME=<name for destructuring parameter 0> TYPE=LA; INDEX=3
// VARIABLE : NAME=continuation TYPE=Lkotlin/coroutines/experimental/Continuation; INDEX=2
// VARIABLE : NAME=$x_param_y_param TYPE=LA; INDEX=5
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=6
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=7
// VARIABLE : NAME=$i$a$2$foo TYPE=I INDEX=2
// VARIABLE : NAME=a$iv TYPE=LA; INDEX=1
// VARIABLE : NAME=$i$f$foo TYPE=I INDEX=8