Removed 'INSTANCE' field from companions
This commit is contained in:
@@ -840,17 +840,16 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateFieldForSingleton() {
|
private void generateFieldForSingleton() {
|
||||||
if (isEnumEntry(descriptor)) return;
|
if (isEnumEntry(descriptor) || isCompanionObject(descriptor)) return;
|
||||||
|
|
||||||
boolean isCompanionObject = isCompanionObject(descriptor);
|
if (isNonCompanionObject(descriptor)) {
|
||||||
if (isNonCompanionObject(descriptor) || isCompanionObject) {
|
|
||||||
StackValue.Field field = StackValue.singletonViaInstance(descriptor, typeMapper);
|
StackValue.Field field = StackValue.singletonViaInstance(descriptor, typeMapper);
|
||||||
v.newField(JvmDeclarationOriginKt.OtherOrigin(myClass),
|
v.newField(JvmDeclarationOriginKt.OtherOrigin(myClass),
|
||||||
ACC_PUBLIC | ACC_STATIC | ACC_FINAL | (isCompanionObject ? ACC_DEPRECATED : 0),
|
ACC_PUBLIC | ACC_STATIC | ACC_FINAL,
|
||||||
field.name, field.type.getDescriptor(), null, null);
|
field.name, field.type.getDescriptor(), null, null);
|
||||||
|
|
||||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
||||||
// Invoke the object constructor but ignore the result because INSTANCE$ will be initialized in the first line of <init>
|
// Invoke the object constructor but ignore the result because INSTANCE will be initialized in the first line of <init>
|
||||||
InstructionAdapter v = createOrGetClInitCodegen().v;
|
InstructionAdapter v = createOrGetClInitCodegen().v;
|
||||||
markLineNumberForElement(element, v);
|
markLineNumberForElement(element, v);
|
||||||
v.anew(classAsmType);
|
v.anew(classAsmType);
|
||||||
@@ -869,12 +868,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper);
|
StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper);
|
||||||
v.newField(JvmDeclarationOriginKt.OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
v.newField(JvmDeclarationOriginKt.OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
||||||
|
|
||||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
|
||||||
|
|
||||||
if (!isCompanionObjectWithBackingFieldsInOuter(companionObjectDescriptor)) {
|
|
||||||
generateCompanionObjectInitializer(companionObjectDescriptor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateCompanionObjectBackingFieldCopies() {
|
private void generateCompanionObjectBackingFieldCopies() {
|
||||||
@@ -926,13 +919,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
private void generateCompanionObjectInitializer(@NotNull ClassDescriptor companionObject) {
|
private void generateCompanionObjectInitializer(@NotNull ClassDescriptor companionObject) {
|
||||||
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
||||||
//TODO: uncomment when DEPRECATED INSTANCE is removed
|
|
||||||
//FunctionDescriptor constructor = (FunctionDescriptor) context.accessibleDescriptor(
|
FunctionDescriptor constructor = (FunctionDescriptor) context.accessibleDescriptor(
|
||||||
// CollectionsKt.single(companionObject.getConstructors()), /* superCallExpression = */ null
|
CollectionsKt.single(companionObject.getConstructors()), /* superCallExpression = */ null
|
||||||
//);
|
);
|
||||||
//generateMethodCallTo(constructor, null, codegen.v);
|
generateMethodCallTo(constructor, null, codegen.v);
|
||||||
//StackValue instance = StackValue.onStack(typeMapper.mapClass(companionObject));
|
StackValue instance = StackValue.onStack(typeMapper.mapClass(companionObject));
|
||||||
StackValue.singleton(companionObject, typeMapper).store(StackValue.singletonViaInstance(companionObject, typeMapper), codegen.v, true);
|
StackValue.singleton(companionObject, typeMapper).store(instance, codegen.v, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
||||||
@@ -1002,7 +995,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor,
|
generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor,
|
||||||
getDelegationConstructorCall(bindingContext, constructorDescriptor));
|
getDelegationConstructorCall(bindingContext, constructorDescriptor));
|
||||||
|
|
||||||
if (isObject(descriptor)) {
|
if (isNonCompanionObject(descriptor)) {
|
||||||
StackValue.singletonViaInstance(descriptor, typeMapper).store(StackValue.LOCAL_0, iv);
|
StackValue.singletonViaInstance(descriptor, typeMapper).store(StackValue.LOCAL_0, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,9 +1020,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
curParam++;
|
curParam++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCompanionObject(descriptor)) {
|
||||||
|
ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||||
|
parentCodegen.generateCompanionObjectInitializer(descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
if (isCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
if (isCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||||
final ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
final ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||||
parentCodegen.generateCompanionObjectInitializer(descriptor);
|
|
||||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||||
@Override
|
@Override
|
||||||
public ExpressionCodegen invoke() {
|
public ExpressionCodegen invoke() {
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StackValue generateMethodCallTo(
|
protected StackValue generateMethodCallTo(
|
||||||
@NotNull FunctionDescriptor functionDescriptor,
|
@NotNull FunctionDescriptor functionDescriptor,
|
||||||
@Nullable FunctionDescriptor accessorDescriptor,
|
@Nullable FunctionDescriptor accessorDescriptor,
|
||||||
@NotNull InstructionAdapter iv
|
@NotNull InstructionAdapter iv
|
||||||
|
|||||||
-5
@@ -10,11 +10,6 @@ public final class ClassObjectField {
|
|||||||
public ClassObjectField() { /* compiled code */ }
|
public ClassObjectField() { /* compiled code */ }
|
||||||
|
|
||||||
public static final class Companion {
|
public static final class Companion {
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public static final ClassObjectField.Companion INSTANCE;
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
public final java.lang.String getX() { /* compiled code */ }
|
public final java.lang.String getX() { /* compiled code */ }
|
||||||
|
|
||||||
|
|||||||
Vendored
-4
@@ -7,10 +7,6 @@ public interface TraitClassObjectField {
|
|||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
public static final java.lang.String x = "";
|
public static final java.lang.String x = "";
|
||||||
private static final java.lang.String y = "";
|
private static final java.lang.String y = "";
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public static final TraitClassObjectField.Companion INSTANCE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ public final class C {
|
|||||||
public C() { /* compiled code */ }
|
public C() { /* compiled code */ }
|
||||||
|
|
||||||
public static final class Companion {
|
public static final class Companion {
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public static final C.Companion INSTANCE;
|
|
||||||
|
|
||||||
private Companion() { /* compiled code */ }
|
private Companion() { /* compiled code */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,7 @@ class B {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1 DEPRECATED is for INSTANCE temporarily
|
3 DEPRECATED are for getCONST_VAL
|
||||||
3 others are for getCONST_VAL
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 4 DEPRECATED
|
// 3 DEPRECATED
|
||||||
@@ -7,7 +7,6 @@ syntheticMethods.kt:19
|
|||||||
syntheticMethods.kt:20
|
syntheticMethods.kt:20
|
||||||
syntheticMethods.kt:17
|
syntheticMethods.kt:17
|
||||||
syntheticMethods.kt:7
|
syntheticMethods.kt:7
|
||||||
syntheticMethods.kt:34
|
|
||||||
syntheticMethods.kt:0
|
syntheticMethods.kt:0
|
||||||
syntheticMethods.kt:7
|
syntheticMethods.kt:7
|
||||||
syntheticMethods.kt:25
|
syntheticMethods.kt:25
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ syntheticMethodsSkip.kt:6
|
|||||||
syntheticMethodsSkip.kt:19
|
syntheticMethodsSkip.kt:19
|
||||||
syntheticMethodsSkip.kt:20
|
syntheticMethodsSkip.kt:20
|
||||||
syntheticMethodsSkip.kt:7
|
syntheticMethodsSkip.kt:7
|
||||||
syntheticMethodsSkip.kt:34
|
|
||||||
syntheticMethodsSkip.kt:0
|
syntheticMethodsSkip.kt:0
|
||||||
syntheticMethodsSkip.kt:7
|
syntheticMethodsSkip.kt:7
|
||||||
syntheticMethodsSkip.kt:25
|
syntheticMethodsSkip.kt:25
|
||||||
|
|||||||
Reference in New Issue
Block a user