Don't use direct access to property field in inlined method

This commit is contained in:
Mikhael Bogdanov
2013-09-20 13:14:15 +04:00
parent 4f5b20a8db
commit 2874cd203f
2 changed files with 13 additions and 3 deletions
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
import org.jetbrains.jet.codegen.context.CodegenContext;
import org.jetbrains.jet.codegen.context.MethodContext;
import org.jetbrains.jet.codegen.context.PackageContext;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
@@ -200,7 +201,16 @@ public class CodegenUtil {
return false;
}
public static boolean couldUseDirectAccessToProperty(@NotNull PropertyDescriptor propertyDescriptor, boolean forGetter, boolean isInsideClass, boolean isDelegated) {
public static boolean couldUseDirectAccessToProperty(
@NotNull PropertyDescriptor propertyDescriptor,
boolean forGetter,
boolean isInsideClass,
boolean isDelegated,
MethodContext context
) {
if (context.isInlineFunction()) {
return false;
}
PropertyAccessorDescriptor accessorDescriptor = forGetter ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
boolean specialTypeProperty = isDelegated ||
@@ -1822,7 +1822,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
if (!skipPropertyAccessors) {
if (couldUseDirectAccessToProperty(propertyDescriptor, true, isInsideClass, isDelegatedProperty)) {
if (couldUseDirectAccessToProperty(propertyDescriptor, true, isInsideClass, isDelegatedProperty, context)) {
callableGetter = null;
}
else {
@@ -1846,7 +1846,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (propertyDescriptor.isVar()) {
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
if (setter != null) {
if (couldUseDirectAccessToProperty(propertyDescriptor, false, isInsideClass, isDelegatedProperty)) {
if (couldUseDirectAccessToProperty(propertyDescriptor, false, isInsideClass, isDelegatedProperty, context)) {
callableSetter = null;
}
else {