Generate private suspend functions as private (not synthetic package-private)
#KT-26592 Fixed
This commit is contained in:
@@ -50,7 +50,7 @@ class AccessorForFunctionDescriptor(
|
||||
if (calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
|
||||
userDataMap = LinkedHashMap<CallableDescriptor.UserDataKey<*>, Any>()
|
||||
userDataMap[INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION] =
|
||||
calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
|
||||
calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,9 +232,7 @@ public class DescriptorAsmUtil {
|
||||
int flags = getVisibilityAccessFlag(functionDescriptor, kind);
|
||||
flags |= getVarargsFlag(functionDescriptor);
|
||||
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
||||
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) ||
|
||||
isInlineWithReified(functionDescriptor) ||
|
||||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(DescriptorVisibilities.PRIVATE)) {
|
||||
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) || isInlineWithReified(functionDescriptor)) {
|
||||
flags |= ACC_SYNTHETIC;
|
||||
}
|
||||
return flags;
|
||||
@@ -427,10 +425,6 @@ public class DescriptorAsmUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (memberDescriptor instanceof FunctionDescriptor && ((FunctionDescriptor) memberDescriptor).isSuspend()) {
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
}
|
||||
|
||||
if (memberDescriptor instanceof AccessorForCompanionObjectInstanceFieldDescriptor) {
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
}
|
||||
|
||||
@@ -721,9 +721,16 @@ class CoroutineCodegenForNamedFunction private constructor(
|
||||
}
|
||||
|
||||
val isInterfaceMethod = DescriptorUtils.isInterface(suspendFunctionJvmView.containingDeclaration)
|
||||
val callableAccessorMethod =
|
||||
typeMapper.mapToCallableMethod(
|
||||
context.accessibleDescriptor(suspendFunctionJvmView.unwrapFrontendVersion(), null),
|
||||
// Obtain default impls method for interfaces
|
||||
isInterfaceMethod
|
||||
)
|
||||
|
||||
val callableMethod =
|
||||
typeMapper.mapToCallableMethod(
|
||||
suspendFunctionJvmView,
|
||||
suspendFunctionJvmView.unwrapFrontendVersion(),
|
||||
// Obtain default impls method for interfaces
|
||||
isInterfaceMethod
|
||||
)
|
||||
@@ -736,10 +743,10 @@ class CoroutineCodegenForNamedFunction private constructor(
|
||||
|
||||
if (suspendFunctionJvmView.isOverridable && !isInterfaceMethod && captureThisType != null) {
|
||||
val owner = captureThisType.internalName
|
||||
val impl = callableMethod.getAsmMethod().getImplForOpenMethod(owner)
|
||||
val impl = callableAccessorMethod.getAsmMethod().getImplForOpenMethod(owner)
|
||||
codegen.v.invokestatic(owner, impl.name, impl.descriptor, false)
|
||||
} else {
|
||||
callableMethod.genInvokeInstruction(codegen.v)
|
||||
callableAccessorMethod.genInvokeInstruction(codegen.v)
|
||||
}
|
||||
|
||||
if (inlineClassToBoxInInvokeSuspend != null) {
|
||||
|
||||
@@ -493,9 +493,8 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
boxInlineClassBeforeInvoke = true
|
||||
}
|
||||
else -> {
|
||||
val isPrivateFunInvocation =
|
||||
DescriptorVisibilities.isPrivate(functionDescriptor.visibility) && !functionDescriptor.isSuspend
|
||||
invokeOpcode = if (superCall || isPrivateFunInvocation) INVOKESPECIAL else INVOKEVIRTUAL
|
||||
invokeOpcode =
|
||||
if (superCall || DescriptorVisibilities.isPrivate(functionDescriptor.visibility)) INVOKESPECIAL else INVOKEVIRTUAL
|
||||
isInterfaceMember = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_COROUTINES
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@kotlin.Metadata
|
||||
public final class PrivateAccessorKt {
|
||||
// source: 'privateAccessor.kt'
|
||||
synthetic final static method 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
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
public final class A {
|
||||
// source: 'privateSuspendFun.kt'
|
||||
public method <init>(): void
|
||||
synthetic final method foo(p0: java.lang.Object): java.lang.Object
|
||||
private final method foo(p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class PrivateSuspendFunKt {
|
||||
// source: 'privateSuspendFun.kt'
|
||||
synthetic final static method foo(p0: java.lang.Object): java.lang.Object
|
||||
private final static method foo(p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public final class Foo {
|
||||
public final @org.jetbrains.annotations.Nullable method generic(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic final method genericWithReified(p0: java.lang.Object, p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic final method genericWithReified(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private synthetic final method privateInline(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final method privateInline(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final @kotlin.internal.InlineOnly method shouldNotHaveSuffix(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final @org.jetbrains.annotations.Nullable method simple$$forInline(@org.jetbrains.annotations.NotNull p0: kotlin.Unit, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final @org.jetbrains.annotations.Nullable method simple$$forInline(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
@@ -29,7 +29,7 @@ public final class SimpleNamedKt {
|
||||
public final static @org.jetbrains.annotations.Nullable method generic(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic final static method genericWithReified(p0: java.lang.Object, p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic final static method genericWithReified(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private synthetic final static method privateInline(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static method privateInline(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static @kotlin.internal.InlineOnly method shouldNotHaveSuffix(p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static @org.jetbrains.annotations.Nullable method simple$$forInline(@org.jetbrains.annotations.NotNull p0: kotlin.Unit, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
private final static @org.jetbrains.annotations.Nullable method simple$$forInline(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object
|
||||
|
||||
Reference in New Issue
Block a user