KT-4140 VerifyError: Property in class object

#KT-4140  Fixed
This commit is contained in:
Mikhael Bogdanov
2013-10-29 12:21:50 +04:00
parent 12bdf557fa
commit fb39217dc3
4 changed files with 33 additions and 5 deletions
@@ -1661,12 +1661,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetExpression r = getReceiverForSelector(expression);
boolean isSuper = r instanceof JetSuperExpression;
propertyDescriptor = accessiblePropertyDescriptor(propertyDescriptor);
StackValue iValue =
StackValue.Property iValue =
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
if (directToField) {
receiver = StackValue.receiverWithoutReceiverArgument(receiver);
}
receiver.put(receiver.type, v);
//pop receiver via put(VOID_TYPE) in case of access to backing field that moved to outer class!!!
receiver.put(!iValue.isPropertyWithBackingFieldInOuterClass() ? receiver.type : Type.VOID_TYPE, v);
return iValue;
}
@@ -1770,7 +1772,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
@NotNull
public StackValue intermediateValueForProperty(
public StackValue.Property intermediateValueForProperty(
@NotNull PropertyDescriptor propertyDescriptor,
boolean forceField,
@Nullable JetSuperExpression superExpression
@@ -1778,7 +1780,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return intermediateValueForProperty(propertyDescriptor, forceField, superExpression, MethodKind.GENERAL);
}
public StackValue.StackValueWithSimpleReceiver intermediateValueForProperty(
public StackValue.Property intermediateValueForProperty(
@NotNull PropertyDescriptor propertyDescriptor,
boolean forceField,
@Nullable JetSuperExpression superExpression,
@@ -1789,7 +1791,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
boolean isStatic = containingDeclaration instanceof NamespaceDescriptor || isBackingFieldInAnotherClass;
boolean isStatic = containingDeclaration instanceof NamespaceDescriptor;
boolean isSuper = superExpression != null;
boolean isInsideClass = isCallInsideSameClassAsDeclared(propertyDescriptor, context);
boolean isInsideModule = isCallInsideSameModuleAsDeclared(propertyDescriptor, context);
@@ -1813,6 +1815,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (!skipPropertyAccessors) {
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType);
}
isStatic = true;
}
if (!skipPropertyAccessors) {
@@ -905,6 +905,10 @@ public abstract class StackValue {
private String getPropertyName() {
return name;
}
public boolean isPropertyWithBackingFieldInOuterClass() {
return descriptor instanceof AccessorForPropertyBackingFieldInOuterClass;
}
}
private static class Expression extends StackValue {
@@ -0,0 +1,16 @@
class TestObject()
{
class object {
var prop: Int = 1
get() = $prop++
}
}
fun box(): String {
if (TestObject.prop != 1) return "fail 1"
if (TestObject.prop != 2) return "fail 2"
return "OK"
}
@@ -3905,6 +3905,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/properties/kt3556.kt");
}
@TestMetadata("kt4140.kt")
public void testKt4140() throws Exception {
doTest("compiler/testData/codegen/box/properties/kt4140.kt");
}
@TestMetadata("kt613.kt")
public void testKt613() throws Exception {
doTest("compiler/testData/codegen/box/properties/kt613.kt");