ambiguous constants references: shadowing (IDEA-146058)

This commit is contained in:
Anna Kozlova
2016-06-06 19:00:36 +03:00
parent de32360bd1
commit 5f7200897e
3 changed files with 35 additions and 3 deletions

View File

@@ -69,10 +69,10 @@ public class JavaVariableConflictResolver implements PsiConflictResolver{
Boolean oldClassIsInheritor = null;
if (newClass != null && oldClass != null) {
if (newClass.isInheritor(oldClass, true)) {
if (!(scope instanceof PsiClass) ||
scope.equals(oldClass) ||
if (scope != null &&
(scope.equals(oldClass) ||
scope.equals(newClass) ||
!((PsiClass)scope).isInheritorDeep(oldClass, newClass)) {
!((PsiClass)scope).isInheritorDeep(oldClass, newClass))) {
// candidate is better
conflicts.remove(currentResult);
currentResult = candidate;

View File

@@ -0,0 +1,28 @@
class MultipleInheritance {
interface A {
int X = 1;
}
interface B extends A {
int X = 2;
}
interface C extends A, B {
int Y = C.<error descr="Reference to 'X' is ambiguous, both 'A.X' and 'B.X' match">X</error>;
}
}
class Shadowing {
interface A {
int X = 1;
}
interface B extends A {
int X = 2;
}
interface C extends B {
int Y = C.X;
}
}

View File

@@ -379,6 +379,10 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest(false, false);
}
public void testAmbiguousConstants() throws Exception {
doTest(false, false);
}
public void testInsane() throws IOException {
configureFromFileText("x.java", "class X { \nx_x_x_x\n }");
List<HighlightInfo> infos = highlightErrors();