mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-psi] Static interface method accessible through inheritance should not shadow static import
Fixes IDEA-355152 Good code red when static import collides with static interface method from the hierarchy GitOrigin-RevId: f6f68cc372928d98bb1f66f2c3ddfaaf63d69702
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2854de57c0
commit
f3a9cdfdab
+5
-3
@@ -10,6 +10,7 @@ import com.intellij.psi.scope.PsiConflictResolver;
|
||||
import com.intellij.psi.scope.conflictResolvers.DuplicateConflictResolver;
|
||||
import com.intellij.psi.util.ImportsUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -113,9 +114,10 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
|
||||
private boolean isShadowed(@NotNull PsiMethod candidate) {
|
||||
if (myCurrentFileContext instanceof PsiImportStaticStatement) {
|
||||
for (JavaResolveResult result : getResults()) {
|
||||
if (result.getElement() != candidate &&
|
||||
result.isAccessible() &&
|
||||
!(result.getCurrentFileResolveScope() instanceof PsiImportStaticStatement)) return true;
|
||||
PsiMethod method = ObjectUtils.tryCast(result.getElement(), PsiMethod.class);
|
||||
if (method != null && method != candidate && result.isAccessible() &&
|
||||
!(result.getCurrentFileResolveScope() instanceof PsiImportStaticStatement) &&
|
||||
isInterfaceStaticMethodAccessibleThroughInheritance(method)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import static java.util.Arrays.copyOf;
|
||||
|
||||
import java.util.AbstractList;
|
||||
|
||||
// IDEA-355152
|
||||
class Main<T> extends AbstractList<T> {
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected static class Node {
|
||||
protected void copy() {
|
||||
int[] ary = new int[]{1,2,3,4,5};
|
||||
copyOf(ary, 6);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Main<String> main = new Main<>();
|
||||
}
|
||||
}
|
||||
+4
@@ -38,6 +38,10 @@ class LightJava11HighlightingTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testStaticImportArrayCopyOfAccess() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testJavaShebang() {
|
||||
val file = myFixture.configureByText("hello",
|
||||
"""#!/path/to/java
|
||||
|
||||
Reference in New Issue
Block a user