diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 8ae2db2ab9c..487b9c34036 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -485,7 +485,10 @@ class ExpressionCodegen( !symbol.owner.isSuspend || !irFunction.shouldContainSuspendMarkers() -> false // Copy-pasted bytecode blocks are not suspension points. symbol.owner.isInline -> - symbol.owner.fqNameForIrSerialization == FqName("kotlin.coroutines.intrinsics.IntrinsicsKt.suspendCoroutineUninterceptedOrReturn") + symbol.owner.let { + it.name.asString() == "suspendCoroutineUninterceptedOrReturn" && + it.getPackageFragment()?.fqName == FqName("kotlin.coroutines.intrinsics") + } // This includes inline lambdas, but only in functions intended for the inliner; in others, they stay as `f.invoke()`. dispatchReceiver.isReadOfInlineLambda() -> irFunction.origin != FOR_INLINE_STATE_MACHINE_TEMPLATE && irFunction.origin != FOR_INLINE_STATE_MACHINE_TEMPLATE_CAPTURES_CROSSINLINE && diff --git a/compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt b/compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt new file mode 100644 index 00000000000..90f76019240 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt @@ -0,0 +1,33 @@ +// FILE: Intrinsics.kt +@file:kotlin.jvm.JvmName("IntrinsicsKt") +@file:kotlin.jvm.JvmMultifileClass + +package kotlin.coroutines.intrinsics + +import kotlin.coroutines.* +import kotlin.internal.InlineOnly + +@InlineOnly +@Suppress("UNUSED_PARAMETER", "RedundantSuspendModifier") +public suspend inline fun suspendCoroutineUninterceptedOrReturn(crossinline block: (Continuation) -> Any?): T = + throw NotImplementedError("Implementation of suspendCoroutineUninterceptedOrReturn is intrinsic") + +// FILE: Annotations.kt +package kotlin.internal + +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) +@Retention(AnnotationRetention.BINARY) +internal annotation class InlineOnly + +// FILE: test.kt +package kotlin.coroutines + +import kotlin.coroutines.intrinsics.* +import kotlin.internal.InlineOnly + +@InlineOnly +public suspend inline fun suspendTest(crossinline block: (Continuation) -> Unit): T = + suspendCoroutineUninterceptedOrReturn { c: Continuation -> } + +// @kotlin/coroutines/TestKt.class: +// 2 InlineMarker.mark diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index ef7abccb5ff..5883a621fec 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -399,6 +399,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/superFlagInMultiFileFacade.kt"); } + @TestMetadata("suspendCoroutineUninterceptedOrReturn.kt") + public void testSuspendCoroutineUninterceptedOrReturn() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt"); + } + @TestMetadata("topLevelFunWithDefaultArgs.kt") public void testTopLevelFunWithDefaultArgs() throws Exception { runTest("compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index 94d00b8a5d2..eb2ae03ca57 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -399,6 +399,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/superFlagInMultiFileFacade.kt"); } + @TestMetadata("suspendCoroutineUninterceptedOrReturn.kt") + public void testSuspendCoroutineUninterceptedOrReturn() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt"); + } + @TestMetadata("topLevelFunWithDefaultArgs.kt") public void testTopLevelFunWithDefaultArgs() throws Exception { runTest("compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt");