Lateinit property backing field now inherits visibility from the property setter
This commit is contained in:
@@ -311,6 +311,7 @@ public class PropertyCodegen {
|
||||
|
||||
FieldOwnerContext backingFieldContext = context;
|
||||
boolean takeVisibilityFromDescriptor = propertyDescriptor.isLateInit() || propertyDescriptor.isConst();
|
||||
boolean takeVisibilityFromSetter = propertyDescriptor.isLateInit() && propertyDescriptor.getSetter() != null;
|
||||
if (AsmUtil.isInstancePropertyWithStaticBackingField(propertyDescriptor) ) {
|
||||
modifiers |= ACC_STATIC;
|
||||
|
||||
@@ -338,6 +339,10 @@ public class PropertyCodegen {
|
||||
modifiers |= ACC_DEPRECATED;
|
||||
}
|
||||
}
|
||||
else if (takeVisibilityFromSetter) {
|
||||
// For lateinits, we take visibility from setter, if any
|
||||
modifiers |= getVisibilityAccessFlag(propertyDescriptor.getSetter());
|
||||
}
|
||||
else if (takeVisibilityFromDescriptor) {
|
||||
modifiers |= getVisibilityAccessFlag(propertyDescriptor);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class My {
|
||||
lateinit var s: String
|
||||
private set
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: My, getS
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL
|
||||
@@ -0,0 +1,8 @@
|
||||
class My {
|
||||
lateinit var s: String
|
||||
private set
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: My, s
|
||||
// FLAGS: ACC_PRIVATE
|
||||
@@ -0,0 +1,7 @@
|
||||
class My {
|
||||
lateinit var s: String
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: My, s
|
||||
// FLAGS: ACC_PUBLIC
|
||||
@@ -626,6 +626,33 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/lateinit")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Lateinit extends AbstractWriteFlagsTest {
|
||||
public void testAllFilesPresentInLateinit() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/lateinit"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("lateinitGetter.kt")
|
||||
public void testLateinitGetter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/lateinit/lateinitGetter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lateinitProperty.kt")
|
||||
public void testLateinitProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/lateinit/lateinitProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lateinitPropertyNoSetter.kt")
|
||||
public void testLateinitPropertyNoSetter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/lateinit/lateinitPropertyNoSetter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/property")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user