diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index 3a307ce6802..d410b75f43b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.backend.jvm.localDeclarationsPhase import org.jetbrains.kotlin.codegen.coroutines.* import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX import org.jetbrains.kotlin.descriptors.DescriptorVisibilities +import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.builders.* @@ -208,10 +209,8 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower } } - private fun Name.toSuspendImplementationName() = when { - isSpecial -> Name.special(asString() + SUSPEND_IMPL_NAME_SUFFIX) - else -> Name.identifier(asString() + SUSPEND_IMPL_NAME_SUFFIX) - } + private fun Name.toSuspendImplementationName(): Name = + Name.guessByFirstCharacter(asString() + SUSPEND_IMPL_NAME_SUFFIX) private fun createStaticSuspendImpl(irFunction: IrSimpleFunction): IrSimpleFunction { // Create static suspend impl method. @@ -220,6 +219,8 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower irFunction.name.toSuspendImplementationName(), irFunction, origin = JvmLoweredDeclarationOrigin.SUSPEND_IMPL_STATIC_FUNCTION, + modality = Modality.OPEN, + visibility = JavaDescriptorVisibilities.PACKAGE_VISIBILITY, isFakeOverride = false, copyMetadata = false ) diff --git a/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.kt b/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.kt new file mode 100644 index 00000000000..4e0df96c0f6 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.kt @@ -0,0 +1,5 @@ +abstract class A { + public open suspend fun public() {} + protected open suspend fun protected() {} + internal open suspend fun internal() {} +} diff --git a/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.txt b/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.txt new file mode 100644 index 00000000000..cb7d7e6d264 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.txt @@ -0,0 +1,11 @@ +@kotlin.Metadata +public abstract class A { + // source: 'suspendImpl.kt' + public method (): void + synthetic static method internal$test_module$suspendImpl(p0: A, p1: java.lang.Object): java.lang.Object + public @org.jetbrains.annotations.Nullable method internal$test_module(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object + synthetic static method protected$suspendImpl(p0: A, p1: java.lang.Object): java.lang.Object + protected @org.jetbrains.annotations.Nullable method protected(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object + synthetic static method public$suspendImpl(p0: A, p1: java.lang.Object): java.lang.Object + public @org.jetbrains.annotations.Nullable method public(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} diff --git a/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl_ir.txt b/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl_ir.txt new file mode 100644 index 00000000000..934e1407436 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl_ir.txt @@ -0,0 +1,11 @@ +@kotlin.Metadata +public abstract class A { + // source: 'suspendImpl.kt' + public method (): void + synthetic static method internal$suspendImpl(p0: A, p1: kotlin.coroutines.Continuation): java.lang.Object + public @org.jetbrains.annotations.Nullable method internal$test_module(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object + synthetic static method protected$suspendImpl(p0: A, p1: kotlin.coroutines.Continuation): java.lang.Object + protected @org.jetbrains.annotations.Nullable method protected(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object + synthetic static method public$suspendImpl(p0: A, p1: kotlin.coroutines.Continuation): java.lang.Object + public @org.jetbrains.annotations.Nullable method public(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index da780c90a5c..b762ed65377 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -697,6 +697,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/coroutines/privateSuspendFun.kt"); } + @TestMetadata("suspendImpl.kt") + public void testSuspendImpl() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.kt"); + } + @TestMetadata("suspendReifiedFun.kt") public void testSuspendReifiedFun_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/bytecodeListing/coroutines/suspendReifiedFun.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 5eda0b8c230..1561bc7a3f1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -677,6 +677,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/coroutines/privateSuspendFun.kt"); } + @TestMetadata("suspendImpl.kt") + public void testSuspendImpl() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/coroutines/suspendImpl.kt"); + } + @TestMetadata("suspendReifiedFun.kt") public void testSuspendReifiedFun_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/bytecodeListing/coroutines/suspendReifiedFun.kt", "kotlin.coroutines");