don't prefer packages in static imports (IDEA-168464)

This commit is contained in:
Anna.Kozlova
2017-02-21 18:18:30 +01:00
parent cc44538f2f
commit 51dde4575e
3 changed files with 13 additions and 1 deletions

View File

@@ -474,7 +474,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
//A single-type-import declaration d in a compilation unit c of package p that imports a type named n shadows, throughout c, the declarations of:
//any top level type named n declared in another compilation unit of p
if (PsiTreeUtil.getParentOfType(this, PsiImportStatementBase.class) != null) {
if (PsiTreeUtil.getParentOfType(this, PsiImportStatement.class) != null) {
JavaResolveResult[] result = resolve(PACKAGE_NAME_KIND, containingFile);
return result.length == 0 ? resolve(classKind, containingFile) : result;
}

View File

@@ -0,0 +1,5 @@
package p2;
import static p.P1.FOO;
class Bar {}

View File

@@ -105,6 +105,13 @@ public class LightAdvHighlightingFixtureTest extends LightCodeInsightFixtureTest
myFixture.checkHighlighting();
}
public void testStaticImportClassConflictingWithPackageName() throws Exception {
myFixture.addClass("package p.P1; class Unrelated {}");
myFixture.addClass("package p; public class P1 {public static final int FOO = 1;}");
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting();
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/advFixture";