Use getfield or putfield instructions for private properties instead of invokevirtual getA or setA
This commit is contained in:
@@ -1537,6 +1537,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
//noinspection ConstantConditions
|
||||
if (isInsideClass &&
|
||||
(propertyDescriptor.getGetter() == null ||
|
||||
!DescriptorUtils.isExternallyAccessible(propertyDescriptor) ||
|
||||
propertyDescriptor.getGetter().isDefault() && propertyDescriptor.getGetter().getModality() == Modality.FINAL)) {
|
||||
getter = null;
|
||||
}
|
||||
@@ -1573,6 +1574,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
//noinspection ConstantConditions
|
||||
if (!propertyDescriptor.isVar() || isInsideClass &&
|
||||
(propertyDescriptor.getSetter() == null ||
|
||||
!DescriptorUtils.isExternallyAccessible(propertyDescriptor) ||
|
||||
propertyDescriptor.getSetter().isDefault() &&
|
||||
propertyDescriptor.getSetter().getModality() == Modality.FINAL)) {
|
||||
setter = null;
|
||||
|
||||
@@ -43,6 +43,7 @@ import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isExternallyAccessible;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
|
||||
/**
|
||||
@@ -140,11 +141,6 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isExternallyAccessible(PropertyDescriptor p) {
|
||||
return p.getVisibility() != Visibilities.PRIVATE || DescriptorUtils.isClassObject(p.getContainingDeclaration())
|
||||
|| p.getContainingDeclaration() instanceof NamespaceDescriptor;
|
||||
}
|
||||
|
||||
private void generateSetter(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
||||
JetPropertyAccessor setter = p.getSetter();
|
||||
if (setter != null && setter.getBodyExpression() != null) {
|
||||
|
||||
Reference in New Issue
Block a user