KT-4140 VerifyError: Property in class object
#KT-4140 Fixed
This commit is contained in:
@@ -1661,12 +1661,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
JetExpression r = getReceiverForSelector(expression);
|
JetExpression r = getReceiverForSelector(expression);
|
||||||
boolean isSuper = r instanceof JetSuperExpression;
|
boolean isSuper = r instanceof JetSuperExpression;
|
||||||
propertyDescriptor = accessiblePropertyDescriptor(propertyDescriptor);
|
propertyDescriptor = accessiblePropertyDescriptor(propertyDescriptor);
|
||||||
StackValue iValue =
|
StackValue.Property iValue =
|
||||||
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
|
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
|
||||||
if (directToField) {
|
if (directToField) {
|
||||||
receiver = StackValue.receiverWithoutReceiverArgument(receiver);
|
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;
|
return iValue;
|
||||||
}
|
}
|
||||||
@@ -1770,7 +1772,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public StackValue intermediateValueForProperty(
|
public StackValue.Property intermediateValueForProperty(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
boolean forceField,
|
boolean forceField,
|
||||||
@Nullable JetSuperExpression superExpression
|
@Nullable JetSuperExpression superExpression
|
||||||
@@ -1778,7 +1780,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
return intermediateValueForProperty(propertyDescriptor, forceField, superExpression, MethodKind.GENERAL);
|
return intermediateValueForProperty(propertyDescriptor, forceField, superExpression, MethodKind.GENERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StackValue.StackValueWithSimpleReceiver intermediateValueForProperty(
|
public StackValue.Property intermediateValueForProperty(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
boolean forceField,
|
boolean forceField,
|
||||||
@Nullable JetSuperExpression superExpression,
|
@Nullable JetSuperExpression superExpression,
|
||||||
@@ -1789,7 +1791,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||||
|
|
||||||
boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||||
boolean isStatic = containingDeclaration instanceof NamespaceDescriptor || isBackingFieldInAnotherClass;
|
boolean isStatic = containingDeclaration instanceof NamespaceDescriptor;
|
||||||
boolean isSuper = superExpression != null;
|
boolean isSuper = superExpression != null;
|
||||||
boolean isInsideClass = isCallInsideSameClassAsDeclared(propertyDescriptor, context);
|
boolean isInsideClass = isCallInsideSameClassAsDeclared(propertyDescriptor, context);
|
||||||
boolean isInsideModule = isCallInsideSameModuleAsDeclared(propertyDescriptor, context);
|
boolean isInsideModule = isCallInsideSameModuleAsDeclared(propertyDescriptor, context);
|
||||||
@@ -1813,6 +1815,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
if (!skipPropertyAccessors) {
|
if (!skipPropertyAccessors) {
|
||||||
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType);
|
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType);
|
||||||
}
|
}
|
||||||
|
isStatic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skipPropertyAccessors) {
|
if (!skipPropertyAccessors) {
|
||||||
|
|||||||
@@ -905,6 +905,10 @@ public abstract class StackValue {
|
|||||||
private String getPropertyName() {
|
private String getPropertyName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPropertyWithBackingFieldInOuterClass() {
|
||||||
|
return descriptor instanceof AccessorForPropertyBackingFieldInOuterClass;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Expression extends StackValue {
|
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");
|
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")
|
@TestMetadata("kt613.kt")
|
||||||
public void testKt613() throws Exception {
|
public void testKt613() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/properties/kt613.kt");
|
doTest("compiler/testData/codegen/box/properties/kt613.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user