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
This commit is contained in:
Ilmir Usmanov
2018-03-28 15:46:03 +03:00
parent 712a796637
commit f507a26a12
10 changed files with 234 additions and 4 deletions

View File

@@ -0,0 +1,10 @@
data class A(val x: String, val y: String)
suspend inline fun foo(a: A, block: suspend (A) -> String): String = block(a)
// FILE: test.kt
suspend fun test() = foo(A("O", "K")) { (x_param, y_param) -> x_param + y_param }
// @TestKt.class:
// 1 LOCALVARIABLE x_param Ljava/lang/String;
// 1 LOCALVARIABLE y_param Ljava/lang/String;