Files
kotlin/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/underscoreNames.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

18 lines
772 B
Kotlin
Vendored

class A {
operator fun component1() = "O"
operator fun component2(): String = throw RuntimeException("fail 0")
operator fun component3() = "K"
}
suspend fun foo(a: A, block: suspend (A) -> String): String = block(a)
suspend fun test() = foo(A()) { (x_param, _, y_param) -> x_param + y_param }
// METHOD : UnderscoreNamesKt$test$2.doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
// VARIABLE : NAME=this TYPE=LUnderscoreNamesKt$test$2; INDEX=0
// VARIABLE : NAME=data TYPE=Ljava/lang/Object; INDEX=1
// VARIABLE : NAME=throwable TYPE=Ljava/lang/Throwable; INDEX=2
// VARIABLE : NAME=$x_param_$_$_y_param TYPE=LA; INDEX=3
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=4
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=5