JVM IR: fix visibility/modality of $suspendImpl methods
#KT-43614 Fixed
This commit is contained in:
+5
-4
@@ -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
|
||||
)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
abstract class A {
|
||||
public open suspend fun public() {}
|
||||
protected open suspend fun protected() {}
|
||||
internal open suspend fun internal() {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@kotlin.Metadata
|
||||
public abstract class A {
|
||||
// source: 'suspendImpl.kt'
|
||||
public method <init>(): 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
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@kotlin.Metadata
|
||||
public abstract class A {
|
||||
// source: 'suspendImpl.kt'
|
||||
public method <init>(): 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
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user