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
@@ -1081,6 +1081,24 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("compiler/testData/codegen/bytecodeText/coroutines/destructuringInLambda")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DestructuringInLambda extends AbstractBytecodeTextTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInDestructuringInLambda() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/coroutines/destructuringInLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("inlineSeparateFiles.kt")
public void testInlineSeparateFiles() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/coroutines/destructuringInLambda/inlineSeparateFiles.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)