Make inline class wrapper constructor private
This commit is contained in:
@@ -222,7 +222,7 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static int getMethodAsmFlags(FunctionDescriptor functionDescriptor, OwnerKind kind, GenerationState state) {
|
||||
int flags = getCommonCallableFlags(functionDescriptor, state);
|
||||
int flags = getCommonCallableFlags(functionDescriptor, kind, state);
|
||||
|
||||
for (AnnotationCodegen.JvmFlagAnnotation flagAnnotation : AnnotationCodegen.METHOD_FLAGS) {
|
||||
flags |= flagAnnotation.getJvmFlag(functionDescriptor.getOriginal());
|
||||
@@ -263,14 +263,22 @@ public class AsmUtil {
|
||||
return flags;
|
||||
}
|
||||
|
||||
private static boolean isInlineClassWrapperConstructor(@NotNull FunctionDescriptor functionDescriptor, @NotNull OwnerKind kind) {
|
||||
private static boolean isInlineClassWrapperConstructor(@NotNull FunctionDescriptor functionDescriptor, @Nullable OwnerKind kind) {
|
||||
if (!(functionDescriptor instanceof ConstructorDescriptor)) return false;
|
||||
ClassDescriptor classDescriptor = ((ConstructorDescriptor) functionDescriptor).getConstructedClass();
|
||||
return classDescriptor.isInline() && kind == OwnerKind.IMPLEMENTATION;
|
||||
}
|
||||
|
||||
public static int getCommonCallableFlags(FunctionDescriptor functionDescriptor, @NotNull GenerationState state) {
|
||||
int flags = getVisibilityAccessFlag(functionDescriptor);
|
||||
return getCommonCallableFlags(functionDescriptor, null, state);
|
||||
}
|
||||
|
||||
private static int getCommonCallableFlags(
|
||||
FunctionDescriptor functionDescriptor,
|
||||
@Nullable OwnerKind kind,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
int flags = getVisibilityAccessFlag(functionDescriptor, kind);
|
||||
flags |= getVarargsFlag(functionDescriptor);
|
||||
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
||||
if (state.getDeprecationProvider().isDeprecatedHidden(functionDescriptor) ||
|
||||
@@ -281,7 +289,11 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static int getVisibilityAccessFlag(@NotNull MemberDescriptor descriptor) {
|
||||
Integer specialCase = specialCaseVisibility(descriptor);
|
||||
return getVisibilityAccessFlag(descriptor, null);
|
||||
}
|
||||
|
||||
private static int getVisibilityAccessFlag(@NotNull MemberDescriptor descriptor, @Nullable OwnerKind kind) {
|
||||
Integer specialCase = specialCaseVisibility(descriptor, kind);
|
||||
if (specialCase != null) {
|
||||
return specialCase;
|
||||
}
|
||||
@@ -378,10 +390,15 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Integer specialCaseVisibility(@NotNull MemberDescriptor memberDescriptor) {
|
||||
private static Integer specialCaseVisibility(@NotNull MemberDescriptor memberDescriptor, @Nullable OwnerKind kind) {
|
||||
DeclarationDescriptor containingDeclaration = memberDescriptor.getContainingDeclaration();
|
||||
Visibility memberVisibility = memberDescriptor.getVisibility();
|
||||
|
||||
if (memberDescriptor instanceof FunctionDescriptor &&
|
||||
isInlineClassWrapperConstructor((FunctionDescriptor) memberDescriptor, kind)) {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
|
||||
if (isEffectivelyInlineOnly(memberDescriptor)) {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ public final class Foo {
|
||||
private final field x: int
|
||||
inner class Foo$Companion
|
||||
static method <clinit>(): void
|
||||
public synthetic method <init>(p0: int): void
|
||||
private synthetic method <init>(p0: int): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: int): Foo
|
||||
public static method constructor(p0: int): int
|
||||
public static method equals(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object): boolean
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
@kotlin.Metadata
|
||||
public final class Foo {
|
||||
private final field x: int
|
||||
public synthetic method <init>(p0: int): void
|
||||
private synthetic method <init>(p0: int): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: int): Foo
|
||||
public static method constructor(p0: int): int
|
||||
public static method equals(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object): boolean
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
@kotlin.Metadata
|
||||
public final class Foo {
|
||||
private final field x: int
|
||||
public synthetic method <init>(p0: int): void
|
||||
private synthetic method <init>(p0: int): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: int): Foo
|
||||
public static method constructor(p0: int): int
|
||||
public static method constructor(p0: long): int
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public interface IFoo {
|
||||
@kotlin.Metadata
|
||||
public final class Z {
|
||||
private final field x: int
|
||||
public synthetic method <init>(p0: int): void
|
||||
private synthetic method <init>(p0: int): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: int): Z
|
||||
public static method constructor(p0: int): int
|
||||
public static method constructor(p0: long): int
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ public interface A {
|
||||
@kotlin.Metadata
|
||||
public final class Foo {
|
||||
private final field x: long
|
||||
public synthetic method <init>(p0: long): void
|
||||
private synthetic method <init>(p0: long): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: long): Foo
|
||||
public static method constructor(p0: long): long
|
||||
public method equals(p0: java.lang.Object): boolean
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
@kotlin.Metadata
|
||||
public final class Foo {
|
||||
private final field l: long
|
||||
public synthetic method <init>(p0: long): void
|
||||
private synthetic method <init>(p0: long): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: long): Foo
|
||||
public static method constructor(p0: long): long
|
||||
public final static method empty(p0: long): void
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
|
||||
inline class Z(val x: Int)
|
||||
|
||||
// 1 public synthetic <init>\(I\)V
|
||||
// 1 private synthetic <init>\(I\)V
|
||||
// 1 public static constructor\(I\)I
|
||||
Reference in New Issue
Block a user