Fix for KT-6312: Compiler crashes accessing inherited property of class object
#KT-6312 Fixed
This commit is contained in:
@@ -698,12 +698,16 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static boolean isInstancePropertyWithStaticBackingField(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
return isObject(containingDeclaration) || isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
if (propertyDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isObject(propertyDescriptor.getContainingDeclaration()) || isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
}
|
||||
|
||||
public static boolean isPropertyWithBackingFieldInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
return isClassObjectWithBackingFieldsInOuter(propertyDescriptor.getContainingDeclaration());
|
||||
return propertyDescriptor.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE &&
|
||||
isClassObjectWithBackingFieldsInOuter(propertyDescriptor.getContainingDeclaration());
|
||||
}
|
||||
|
||||
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
open class Bar<T>(val prop: String)
|
||||
class Foo {
|
||||
class object : Bar<Foo>("OK") {
|
||||
val p = Foo.prop
|
||||
val p2 = prop
|
||||
val p3 = this.prop
|
||||
}
|
||||
|
||||
val p4 = Foo.prop
|
||||
val p5 = prop
|
||||
}
|
||||
|
||||
fun box(): String = Foo.prop
|
||||
@@ -0,0 +1,8 @@
|
||||
open class Bar<T>(val prop: String)
|
||||
object Foo : Bar<Foo>("OK") {
|
||||
|
||||
val p = Foo.prop
|
||||
val p2 = prop
|
||||
val p3 = this.prop
|
||||
}
|
||||
fun box(): String = Foo.prop
|
||||
@@ -6241,6 +6241,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedPropertyInClassObject.kt")
|
||||
public void testInheritedPropertyInClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/staticFields/inheritedPropertyInClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedPropertyInObject.kt")
|
||||
public void testInheritedPropertyInObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/staticFields/inheritedPropertyInObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticAccessor.kt")
|
||||
public void testSyntheticAccessor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/staticFields/syntheticAccessor.kt");
|
||||
|
||||
Reference in New Issue
Block a user