Add synthetic flag to generated private suspend functions
Private suspend functions need to be generated as package-local, since they are called from their continuations. However, this means that they can be called from Java, which breaks their private visibility. Adding synthetic to them fixes the issue. #KT-17584: Fixed
This commit is contained in:
@@ -244,7 +244,8 @@ public class AsmUtil {
|
|||||||
int flags = getVisibilityAccessFlag(functionDescriptor);
|
int flags = getVisibilityAccessFlag(functionDescriptor);
|
||||||
flags |= getVarargsFlag(functionDescriptor);
|
flags |= getVarargsFlag(functionDescriptor);
|
||||||
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
||||||
if (state.getDeprecationProvider().isDeprecatedHidden(functionDescriptor)) {
|
if (state.getDeprecationProvider().isDeprecatedHidden(functionDescriptor) ||
|
||||||
|
(functionDescriptor.isSuspend()) && functionDescriptor.getVisibility().equals(Visibilities.PRIVATE)) {
|
||||||
flags |= ACC_SYNTHETIC;
|
flags |= ACC_SYNTHETIC;
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
private suspend fun foo() {}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
private suspend fun foo() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class A {
|
||||||
|
public method <init>(): void
|
||||||
|
synthetic final @org.jetbrains.annotations.Nullable method foo(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class PrivateSuspendFunKt {
|
||||||
|
synthetic final static @org.jetbrains.annotations.Nullable method foo(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object
|
||||||
|
}
|
||||||
@@ -15,6 +15,6 @@ public final class TailCallIntrinsicsKt {
|
|||||||
static method <clinit>(): void
|
static method <clinit>(): void
|
||||||
public final static method getP(): int
|
public final static method getP(): int
|
||||||
public final static method setP(p0: int): void
|
public final static method setP(p0: int): void
|
||||||
final static @org.jetbrains.annotations.Nullable method withInline(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
synthetic final static @org.jetbrains.annotations.Nullable method withInline(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
final static @org.jetbrains.annotations.Nullable method withoutInline(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
synthetic final static @org.jetbrains.annotations.Nullable method withoutInline(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -145,6 +145,12 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateSuspendFun.kt")
|
||||||
|
public void testPrivateSuspendFun() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/privateSuspendFun.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("samAdapterAndInlinedOne.kt")
|
@TestMetadata("samAdapterAndInlinedOne.kt")
|
||||||
public void testSamAdapterAndInlinedOne() throws Exception {
|
public void testSamAdapterAndInlinedOne() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user