diff --git a/compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt b/compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt new file mode 100644 index 00000000000..e51d7bc5689 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt @@ -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() +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index c5b4ea4326f..6495690ade4 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -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"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java index 05ccf6de960..d088f6da55a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java @@ -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;