Fix codegen issue on suspend functions with receiver

When the extension receiver of a named suspend function was marked as used
from the inner lambda, codegen used to throw a "Don't know how to generate outer expression for class" exception.

It may seem quite tricky, but currently for suspend lambda body
its extension receiver is treated as it's defined inside the relevant "doResume"
(there is an actual bytecode part that fills the relevant local variable)

The problem was that inside ExpressionCodegen for "doResume" of named
suspend function we couldn't determine that original function has
an extension receiver.

 #KT-15821 Fixed
 #KT-15820 Fixed
This commit is contained in:
Denis Zharkov
2017-01-22 19:33:11 +03:00
parent 131c008ba3
commit 0693bd6b62
12 changed files with 240 additions and 16 deletions
@@ -5161,12 +5161,24 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis
doTest(fileName);
}
@TestMetadata("inlineTwoReceivers.kt")
public void testInlineTwoReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/inlineTwoReceivers.kt");
doTest(fileName);
}
@TestMetadata("member.kt")
public void testMember() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/member.kt");
doTest(fileName);
}
@TestMetadata("noinlineTwoReceivers.kt")
public void testNoinlineTwoReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/noinlineTwoReceivers.kt");
doTest(fileName);
}
@TestMetadata("returnNoSuspend.kt")
public void testReturnNoSuspend() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/returnNoSuspend.kt");