Hack attributes for continuation of suspend function in SAM-adapter
This commit is contained in:
Generated
+5
@@ -7073,6 +7073,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInterface.kt")
|
||||||
|
public void testFunInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineSuspendFinally.kt")
|
@TestMetadata("inlineSuspendFinally.kt")
|
||||||
public void testInlineSuspendFinally_1_3() throws Exception {
|
public void testInlineSuspendFinally_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt", "kotlin.coroutines");
|
||||||
|
|||||||
+11
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.utils.DFS
|
import org.jetbrains.kotlin.utils.DFS
|
||||||
|
import org.jetbrains.org.objectweb.asm.Type
|
||||||
|
|
||||||
internal val addContinuationPhase = makeIrFilePhase(
|
internal val addContinuationPhase = makeIrFilePhase(
|
||||||
::AddContinuationLowering,
|
::AddContinuationLowering,
|
||||||
@@ -597,6 +598,16 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
|||||||
val result = mutableListOf(view)
|
val result = mutableListOf(view)
|
||||||
if (function.body == null || !function.hasContinuation()) return result
|
if (function.body == null || !function.hasContinuation()) return result
|
||||||
|
|
||||||
|
// This is a suspend function inside of SAM adapter.
|
||||||
|
// The attribute of function reference is used for the SAM adapter.
|
||||||
|
// So, we hack new attributes for continuation class.
|
||||||
|
if (function.parentAsClass.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL) {
|
||||||
|
context.putLocalClassType(
|
||||||
|
function.attributeOwnerId,
|
||||||
|
Type.getObjectType("${context.getLocalClassType(function.parentAsClass)!!.internalName}$${function.name}$1")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (flag.capturesCrossinline || function.isInline) {
|
if (flag.capturesCrossinline || function.isInline) {
|
||||||
result += context.irFactory.buildFun {
|
result += context.irFactory.buildFun {
|
||||||
containerSource = view.containerSource
|
containerSource = view.containerSource
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
import helpers.*
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
fun interface Action {
|
||||||
|
suspend fun run()
|
||||||
|
}
|
||||||
|
suspend fun runAction(a: Action) {
|
||||||
|
a.run()
|
||||||
|
}
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(EmptyContinuation)
|
||||||
|
}
|
||||||
|
fun box(): String {
|
||||||
|
var res = "FAIL"
|
||||||
|
builder {
|
||||||
|
runAction {
|
||||||
|
res = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
+5
@@ -7673,6 +7673,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInterface.kt")
|
||||||
|
public void testFunInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineSuspendFinally.kt")
|
@TestMetadata("inlineSuspendFinally.kt")
|
||||||
public void testInlineSuspendFinally_1_2() throws Exception {
|
public void testInlineSuspendFinally_1_2() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt", "kotlin.coroutines.experimental");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt", "kotlin.coroutines.experimental");
|
||||||
|
|||||||
+5
@@ -7631,6 +7631,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class FeatureIntersection extends AbstractLightAnalysisModeTest {
|
public static class FeatureIntersection extends AbstractLightAnalysisModeTest {
|
||||||
|
@TestMetadata("funInterface.kt")
|
||||||
|
public void ignoreFunInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt");
|
||||||
|
}
|
||||||
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -7073,6 +7073,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInterface.kt")
|
||||||
|
public void testFunInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineSuspendFinally.kt")
|
@TestMetadata("inlineSuspendFinally.kt")
|
||||||
public void testInlineSuspendFinally_1_3() throws Exception {
|
public void testInlineSuspendFinally_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt", "kotlin.coroutines");
|
||||||
|
|||||||
Reference in New Issue
Block a user