mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] fixed hiding of constants during overload resolution (IDEA-287953)
GitOrigin-RevId: 5de6c138d9ac051af5b41d50c88a9b8b508e86bf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
33d764b241
commit
37419d54aa
+4
-2
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.scope.conflictResolvers;
|
||||
|
||||
import com.intellij.psi.PsiAnonymousClass;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiField;
|
||||
@@ -91,7 +92,8 @@ public class JavaVariableConflictResolver implements PsiConflictResolver{
|
||||
if (oldClassIsInheritor == null) {
|
||||
oldClassIsInheritor = oldClass != null && newClass != null && oldClass.isInheritor(newClass, true);
|
||||
}
|
||||
if (oldClassIsInheritor) {
|
||||
if (oldClassIsInheritor && (scope instanceof PsiAnonymousClass ||
|
||||
!(scope instanceof PsiClass && ((PsiClass)scope).isInheritorDeep(oldClass, newClass)))) {
|
||||
// both fields are accessible
|
||||
// field in derived hides field in base
|
||||
conflicts.remove(candidate);
|
||||
|
||||
+36
@@ -28,4 +28,40 @@ class Shadowing {
|
||||
interface C extends B {
|
||||
int Y = C.X;
|
||||
}
|
||||
}
|
||||
|
||||
class MultipleInheritance2 {
|
||||
interface I1 {
|
||||
String X = "x";
|
||||
}
|
||||
static class Y implements I1 {
|
||||
public static final String X = "y";
|
||||
}
|
||||
|
||||
static class Z extends Y {
|
||||
{
|
||||
System.out.println(X);
|
||||
}
|
||||
}
|
||||
|
||||
static class Z1 extends Y implements I1 {
|
||||
{
|
||||
System.out.println(<error descr="Reference to 'X' is ambiguous, both 'Y.X' and 'I1.X' match">X</error>);
|
||||
}
|
||||
}
|
||||
|
||||
interface I2 extends I1 {}
|
||||
static class Z2 extends Y implements I2 {
|
||||
{
|
||||
System.out.println(<error descr="Reference to 'X' is ambiguous, both 'Y.X' and 'I1.X' match">X</error>);
|
||||
}
|
||||
}
|
||||
|
||||
static class Z3 extends Y implements Runnable, I2 {
|
||||
{
|
||||
System.out.println(<error descr="Reference to 'X' is ambiguous, both 'Y.X' and 'I1.X' match">X</error>);
|
||||
}
|
||||
|
||||
public void run() {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user