Restrict companion properties copying to interface by const
This commit is contained in:
@@ -703,12 +703,9 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static boolean isPropertyWithBackingFieldCopyInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
|
||||
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
|
||||
return !propertyDescriptor.isVar()
|
||||
&& !isExtensionProperty
|
||||
return propertyDescriptor.isConst()
|
||||
&& isCompanionObject(propertyContainer) && isInterface(propertyContainer.getContainingDeclaration())
|
||||
&& areBothAccessorDefault(propertyDescriptor)
|
||||
&& getVisibilityForSpecialPropertyBackingField(propertyDescriptor, false) == ACC_PUBLIC;
|
||||
}
|
||||
|
||||
|
||||
@@ -873,7 +873,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
PropertyDescriptor property = info.descriptor;
|
||||
|
||||
Type type = typeMapper.mapType(property);
|
||||
int modifiers = ACC_STATIC | ACC_FINAL | ACC_PUBLIC | (property.isConst() ? 0 : ACC_DEPRECATED);
|
||||
int modifiers = ACC_STATIC | ACC_FINAL | ACC_PUBLIC;
|
||||
FieldVisitor fv = v.newField(JvmDeclarationOriginKt.Synthetic(DescriptorToSourceUtils.descriptorToDeclaration(property), property),
|
||||
modifiers, context.getFieldName(property, false),
|
||||
type.getDescriptor(), typeMapper.mapFieldSignature(property.getType(), property),
|
||||
|
||||
-3
@@ -8,9 +8,6 @@ class Test {
|
||||
s = Trait.NAME;
|
||||
if (!s.equals("Trait")) throw new AssertionError("Fail interface: " + s);
|
||||
|
||||
s = Trait.DEPRECATED;
|
||||
if (!s.equals("DEPRECATED")) throw new AssertionError("Fail interface: " + s);
|
||||
|
||||
s = Enoom.NAME;
|
||||
if (!s.equals("Enum")) throw new AssertionError("Fail enum: " + s);
|
||||
|
||||
|
||||
Vendored
-1
@@ -7,7 +7,6 @@ class Klass {
|
||||
interface Trait {
|
||||
companion object {
|
||||
const val NAME = "Trait"
|
||||
val DEPRECATED = "DEPRECATED"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ interface Test {
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: Test, prop
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_STATIC, ACC_DEPRECATED
|
||||
// ABSENT: TRUE
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: Test$Companion, prop
|
||||
|
||||
@@ -6,7 +6,7 @@ interface Test {
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: Test, prop
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_STATIC, ACC_DEPRECATED
|
||||
// ABSENT: TRUE
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: Test$Companion, prop
|
||||
|
||||
Reference in New Issue
Block a user