static import when inheritance present (IDEA-158357)

This commit is contained in:
Anna.Kozlova
2016-07-12 11:08:35 +02:00
parent cf1b458130
commit 2be8a720a8
4 changed files with 19 additions and 3 deletions
@@ -92,7 +92,7 @@ public class ImportsUtil {
if (containingClass != null && stmt.resolveTargetClass() == containingClass) {
if (!stmt.isOnDemand() && Comparing.strEqual(referenceName, member.getName())) {
if (member instanceof PsiMethod) {
return containingClass.findMethodsByName(referenceName, false).length == 1;
return containingClass.findMethodsByName(referenceName, false).length > 0;
}
return true;
}
@@ -0,0 +1,9 @@
package a;
import static a.A.foo;
interface B extends A {
static void bar() {
foo("");
}
}
@@ -1,7 +1,7 @@
import bar.A;
import static bar.A.foo;
class Usage {
void bar() {
A.foo();
foo();
}
}
@@ -56,6 +56,13 @@ public class LightAdvHighlightingFixtureTest extends LightCodeInsightFixtureTest
myFixture.checkHighlighting();
}
public void testStaticImportCompoundWithInheritance() throws Exception {
myFixture.addClass("package a; public interface A { static void foo(Object o){} static void foo(String str) {}}");
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting();
}
public void testSuppressedInGenerated() throws Exception {
myFixture.addClass("package javax.annotation; public @interface Generated {}");
final RedundantCastInspection inspection = new RedundantCastInspection();