JVM IR: Do not generate private suspend functions as synthetic package-private
#KT-26592
This commit is contained in:
-1
@@ -165,7 +165,6 @@ class FunctionCodegen(
|
||||
}
|
||||
val isSynthetic = origin.isSynthetic ||
|
||||
hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) ||
|
||||
(isSuspend && DescriptorVisibilities.isPrivate(visibility) && !isInline) ||
|
||||
isReifiable() ||
|
||||
isDeprecatedHidden()
|
||||
|
||||
|
||||
@@ -208,10 +208,6 @@ private fun IrDeclarationWithVisibility.specialCaseVisibility(kind: OwnerKind?):
|
||||
return null
|
||||
}
|
||||
|
||||
if (this is IrSimpleFunction && isSuspend) {
|
||||
return AsmUtil.NO_FLAG_PACKAGE_PRIVATE
|
||||
}
|
||||
|
||||
if (this is IrConstructor && parentAsClass.kind === ClassKind.ENUM_ENTRY) {
|
||||
return AsmUtil.NO_FLAG_PACKAGE_PRIVATE
|
||||
}
|
||||
|
||||
-2
@@ -679,8 +679,6 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
|
||||
val fromSubclassOfReceiversClass = !throughCrossinlineLambda &&
|
||||
context.isSubclassOf(ownerClass) && (thisObjReference == null || context.symbol.isSubtypeOfClass(thisObjReference))
|
||||
return when {
|
||||
// private suspend functions are generated as synthetic package private
|
||||
declaration is IrFunction && declaration.isSuspend && declaration.visibility.isPrivate && samePackage -> true
|
||||
declaration.visibility.isPrivate && (throughCrossinlineLambda || ownerClass != context) -> false
|
||||
declaration.visibility.isProtected && !samePackage && !fromSubclassOfReceiversClass -> false
|
||||
withSuper && !fromSubclassOfReceiversClass -> false
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND: JVM, NATIVE
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
|
||||
// `lambda` should not be wrapped in yet another object (so no OnInlineArgumentKt$box$1$1).
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ final class OnInlineArgumentKt$box$1 {
|
||||
field label: int
|
||||
inner (anonymous) class OnInlineArgumentKt$box$1
|
||||
method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.jvm.functions.Function1, p2: kotlin.coroutines.Continuation): void
|
||||
public synthetic final static method access$invokeSuspend$suspendConversion0(p0: kotlin.jvm.functions.Function1, p1: java.lang.String, p2: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
|
||||
public final @org.jetbrains.annotations.Nullable method invoke(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic bridge method invoke(p0: java.lang.Object): java.lang.Object
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@kotlin.Metadata
|
||||
public final class PrivateAccessorKt {
|
||||
// source: 'privateAccessor.kt'
|
||||
public synthetic final static method access$bar(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static method bar(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static method foo(): void
|
||||
}
|
||||
+4
-2
@@ -2,11 +2,13 @@
|
||||
public final class A {
|
||||
// source: 'privateSuspendFun.kt'
|
||||
public method <init>(): void
|
||||
synthetic final method foo(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic final static method access$foo(p0: A, p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final method foo(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class PrivateSuspendFunKt {
|
||||
// source: 'privateSuspendFun.kt'
|
||||
synthetic final static method foo(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic final static method access$foo(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static method foo(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user