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) {
|
if (calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
|
||||||
userDataMap = LinkedHashMap<CallableDescriptor.UserDataKey<*>, Any>()
|
userDataMap = LinkedHashMap<CallableDescriptor.UserDataKey<*>, Any>()
|
||||||
userDataMap[INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION] =
|
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);
|
int flags = getVisibilityAccessFlag(functionDescriptor, kind);
|
||||||
flags |= getVarargsFlag(functionDescriptor);
|
flags |= getVarargsFlag(functionDescriptor);
|
||||||
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
||||||
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) ||
|
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) || isInlineWithReified(functionDescriptor)) {
|
||||||
isInlineWithReified(functionDescriptor) ||
|
|
||||||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(DescriptorVisibilities.PRIVATE)) {
|
|
||||||
flags |= ACC_SYNTHETIC;
|
flags |= ACC_SYNTHETIC;
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
@@ -427,10 +425,6 @@ public class DescriptorAsmUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memberDescriptor instanceof FunctionDescriptor && ((FunctionDescriptor) memberDescriptor).isSuspend()) {
|
|
||||||
return NO_FLAG_PACKAGE_PRIVATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memberDescriptor instanceof AccessorForCompanionObjectInstanceFieldDescriptor) {
|
if (memberDescriptor instanceof AccessorForCompanionObjectInstanceFieldDescriptor) {
|
||||||
return NO_FLAG_PACKAGE_PRIVATE;
|
return NO_FLAG_PACKAGE_PRIVATE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -721,9 +721,16 @@ class CoroutineCodegenForNamedFunction private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val isInterfaceMethod = DescriptorUtils.isInterface(suspendFunctionJvmView.containingDeclaration)
|
val isInterfaceMethod = DescriptorUtils.isInterface(suspendFunctionJvmView.containingDeclaration)
|
||||||
|
val callableAccessorMethod =
|
||||||
|
typeMapper.mapToCallableMethod(
|
||||||
|
context.accessibleDescriptor(suspendFunctionJvmView.unwrapFrontendVersion(), null),
|
||||||
|
// Obtain default impls method for interfaces
|
||||||
|
isInterfaceMethod
|
||||||
|
)
|
||||||
|
|
||||||
val callableMethod =
|
val callableMethod =
|
||||||
typeMapper.mapToCallableMethod(
|
typeMapper.mapToCallableMethod(
|
||||||
suspendFunctionJvmView,
|
suspendFunctionJvmView.unwrapFrontendVersion(),
|
||||||
// Obtain default impls method for interfaces
|
// Obtain default impls method for interfaces
|
||||||
isInterfaceMethod
|
isInterfaceMethod
|
||||||
)
|
)
|
||||||
@@ -736,10 +743,10 @@ class CoroutineCodegenForNamedFunction private constructor(
|
|||||||
|
|
||||||
if (suspendFunctionJvmView.isOverridable && !isInterfaceMethod && captureThisType != null) {
|
if (suspendFunctionJvmView.isOverridable && !isInterfaceMethod && captureThisType != null) {
|
||||||
val owner = captureThisType.internalName
|
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)
|
codegen.v.invokestatic(owner, impl.name, impl.descriptor, false)
|
||||||
} else {
|
} else {
|
||||||
callableMethod.genInvokeInstruction(codegen.v)
|
callableAccessorMethod.genInvokeInstruction(codegen.v)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlineClassToBoxInInvokeSuspend != null) {
|
if (inlineClassToBoxInInvokeSuspend != null) {
|
||||||
|
|||||||
@@ -493,9 +493,8 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
|||||||
boxInlineClassBeforeInvoke = true
|
boxInlineClassBeforeInvoke = true
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val isPrivateFunInvocation =
|
invokeOpcode =
|
||||||
DescriptorVisibilities.isPrivate(functionDescriptor.visibility) && !functionDescriptor.isSuspend
|
if (superCall || DescriptorVisibilities.isPrivate(functionDescriptor.visibility)) INVOKESPECIAL else INVOKEVIRTUAL
|
||||||
invokeOpcode = if (superCall || isPrivateFunInvocation) INVOKESPECIAL else INVOKEVIRTUAL
|
|
||||||
isInterfaceMember = false
|
isInterfaceMember = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// !JVM_DEFAULT_MODE: all
|
// !JVM_DEFAULT_MODE: all
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// IGNORE_BACKEND: JVM
|
|
||||||
|
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// IGNORE_BACKEND: JVM
|
|
||||||
import helpers.*
|
import helpers.*
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@kotlin.Metadata
|
@kotlin.Metadata
|
||||||
public final class PrivateAccessorKt {
|
public final class PrivateAccessorKt {
|
||||||
// source: 'privateAccessor.kt'
|
// 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
|
private final static method foo(): void
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
public final class A {
|
public final class A {
|
||||||
// source: 'privateSuspendFun.kt'
|
// source: 'privateSuspendFun.kt'
|
||||||
public method <init>(): void
|
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
|
@kotlin.Metadata
|
||||||
public final class PrivateSuspendFunKt {
|
public final class PrivateSuspendFunKt {
|
||||||
// source: 'privateSuspendFun.kt'
|
// 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 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: java.lang.Object, p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||||
public synthetic final method genericWithReified(p0: 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 @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.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
|
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 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: java.lang.Object, p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||||
public synthetic final static method genericWithReified(p0: 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 @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.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
|
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