Generate enum entries classes with package private visibility

#KT-6574 Fixed
This commit is contained in:
Mikhael Bogdanov
2018-09-13 10:34:02 +02:00
parent de989c4050
commit b7afb4a58e
3 changed files with 30 additions and 0 deletions
@@ -407,6 +407,9 @@ public class AsmUtil {
if (ExpectedActualDeclarationChecker.isOptionalAnnotationClass(descriptor)) {
return NO_FLAG_PACKAGE_PRIVATE;
}
if (descriptor.getKind() == ClassKind.ENUM_ENTRY) {
return NO_FLAG_PACKAGE_PRIVATE;
}
if (descriptor.getVisibility() == Visibilities.PUBLIC ||
descriptor.getVisibility() == Visibilities.PROTECTED ||
// TODO: should be package private, but for now Kotlin's reflection can't access members of such classes
@@ -0,0 +1,9 @@
enum class Foo {
A {
fun foo() {}
}
}
// TESTED_OBJECT_KIND: class
// TESTED_OBJECTS: Foo$A
// FLAGS: ACC_FINAL, ACC_SUPER
@@ -248,6 +248,24 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
}
}
@TestMetadata("compiler/testData/writeFlags/class/visibility/packageprivate")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Packageprivate extends AbstractWriteFlagsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInPackageprivate() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/class/visibility/packageprivate"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("enumEntry.kt")
public void testEnumEntry() throws Exception {
runTest("compiler/testData/writeFlags/class/visibility/packageprivate/enumEntry.kt");
}
}
@TestMetadata("compiler/testData/writeFlags/class/visibility/private")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)