Make protected static visibility reach members in the same package

This commit is contained in:
Alexander Udalov
2014-06-16 17:46:10 +04:00
parent 80b7f88c60
commit e31f2cfa23
3 changed files with 29 additions and 0 deletions
@@ -0,0 +1,20 @@
// FILE: test/JavaClass.java
package test;
public class JavaClass {
protected static int field;
protected static String method() {
return "";
}
}
// FILE: test.kt
package test
fun test() {
JavaClass.field
JavaClass.method()
}
@@ -5032,6 +5032,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest("compiler/testData/diagnostics/tests/j+k/packageVisibility.kt");
}
@TestMetadata("protectedStaticSamePackage.kt")
public void testProtectedStaticSamePackage() throws Exception {
doTest("compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt");
}
@TestMetadata("recursiveRawUpperBound.kt")
public void testRecursiveRawUpperBound() throws Exception {
doTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.kt");
@@ -54,6 +54,10 @@ public class JavaVisibilities {
public static final Visibility PROTECTED_STATIC_VISIBILITY = new Visibility("protected_static", false) {
@Override
protected boolean isVisible(@NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) {
if (areInSamePackage(what, from)) {
return true;
}
ClassDescriptor fromClass = DescriptorUtils.getParentOfType(from, ClassDescriptor.class, false);
if (fromClass == null) return false;