mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-67385 (explicitly imported types should shadow inherited ones)
This commit is contained in:
+11
-5
@@ -92,8 +92,12 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isImported(PsiElement fileContext) {
|
||||
return fileContext instanceof PsiImportStatement;
|
||||
}
|
||||
|
||||
private boolean isOnDemand(PsiElement fileContext, PsiClass psiClass) {
|
||||
if (fileContext instanceof PsiImportStatementBase) {
|
||||
if (isImported(fileContext)) {
|
||||
return ((PsiImportStatementBase)fileContext).isOnDemand();
|
||||
}
|
||||
String fqn = psiClass.getQualifiedName();
|
||||
@@ -118,10 +122,12 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
if (fqName.equals(otherQName)) {
|
||||
return Domination.DOMINATED_BY;
|
||||
}
|
||||
final PsiClass containingclass1 = aClass.getContainingClass();
|
||||
final PsiClass containingclass2 = otherClass.getContainingClass();
|
||||
if (containingclass1 != null && containingclass2 != null && containingclass2.isInheritor(containingclass1, true)) {
|
||||
//shadowing
|
||||
|
||||
final PsiClass containingClass1 = aClass.getContainingClass();
|
||||
final PsiClass containingClass2 = otherClass.getContainingClass();
|
||||
if (containingClass1 != null && containingClass2 != null && containingClass2.isInheritor(containingClass1, true) &&
|
||||
!isImported(myCurrentFileContext)) {
|
||||
// shadowing
|
||||
return Domination.DOMINATED_BY;
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import p.Base.*;
|
||||
import p.BaseImpl;
|
||||
|
||||
class Test extends BaseImpl {
|
||||
void m() {
|
||||
Inner inner = new Inner() { }; // imported public Base.Inner should shadow inherited package-private BaseImpl.Inner
|
||||
BaseImpl.<error descr="'p.BaseImpl.Inner' is not public in 'p.BaseImpl'. Cannot be accessed from outside package">Inner</error> i2 = null;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public interface Base {
|
||||
interface Inner { }
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public class BaseImpl implements Base {
|
||||
static class Inner implements Inner { }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import p.Base.Inner;
|
||||
import p.BaseImpl;
|
||||
|
||||
class Test extends BaseImpl {
|
||||
void m() {
|
||||
Inner inner = new Inner() { }; // imported public Base.Inner should shadow inherited package-private BaseImpl.Inner
|
||||
BaseImpl.<error descr="'p.BaseImpl.Inner' is not public in 'p.BaseImpl'. Cannot be accessed from outside package">Inner</error> i2 = null;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public interface Base {
|
||||
interface Inner { }
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public class BaseImpl implements Base {
|
||||
static class Inner implements BaseImpl.Inner { }
|
||||
}
|
||||
@@ -72,6 +72,8 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
public void testImportOnDemand() throws Exception { doTest(BASE_PATH+"/importOnDemand/y/Y.java", BASE_PATH+"/importOnDemand", false, false); }
|
||||
public void testImportOnDemandVsSingle() throws Exception { doTest(BASE_PATH+"/importOnDemandVsSingle/y/Y.java", BASE_PATH+"/importOnDemandVsSingle", false, false); }
|
||||
public void testImportSingleVsSamePackage() throws Exception { doTest(BASE_PATH+"/importSingleVsSamePackage/y/Y.java", BASE_PATH+"/importSingleVsSamePackage", false, false); }
|
||||
public void testImportSingleVsInherited() throws Exception { doTest(BASE_PATH + "/importSingleVsInherited/Test.java", BASE_PATH + "/importSingleVsInherited", false, false); }
|
||||
public void testImportOnDemandVsInherited() throws Exception { doTest(BASE_PATH + "/importOnDemandVsInherited/Test.java", BASE_PATH + "/importOnDemandVsInherited", false, false); }
|
||||
|
||||
public void testOverridePackageLocal() throws Exception { doTest(BASE_PATH+"/overridePackageLocal/x/y/Derived.java", BASE_PATH+"/overridePackageLocal", false, false); }
|
||||
public void testAlreadyImportedClass() throws Exception { doTest(BASE_PATH+"/alreadyImportedClass/pack/AlreadyImportedClass.java", BASE_PATH+"/alreadyImportedClass", false, false); }
|
||||
|
||||
Reference in New Issue
Block a user