mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
decode: don't qualify 'ambiguous' reference if qualifier is available through inheritance (IDEA-142703)
This commit is contained in:
@@ -202,7 +202,10 @@ public class ChangeContextUtil {
|
||||
if (refMember.hasModifierProperty(PsiModifier.STATIC)){
|
||||
PsiElement refElement = refExpr.resolve();
|
||||
if (!manager.areElementsEquivalent(refMember, refElement)){
|
||||
refExpr.setQualifierExpression(factory.createReferenceExpression(containingClass));
|
||||
final PsiClass currentClass = PsiTreeUtil.getParentOfType(refExpr, PsiClass.class);
|
||||
if (currentClass == null || !InheritanceUtil.isInheritorOrSelf(currentClass, containingClass, true)) {
|
||||
refExpr.setQualifierExpression(factory.createReferenceExpression(containingClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package p1;
|
||||
public class StaticMethod {
|
||||
public static int bar() {return 1;}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package p2;
|
||||
import p1.StaticMethod;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
public class Test extends BigDecimal {
|
||||
Test() {super(0);}
|
||||
void test() {
|
||||
valueOf(0);
|
||||
valueOf(StaticMethod.bar());
|
||||
valueOf(StaticMethod.bar());
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package p1;
|
||||
public class StaticMethod {
|
||||
public static int bar() {return 1;}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package p1;
|
||||
import java.math.BigDecimal;
|
||||
public class Test extends BigDecimal {
|
||||
Test() {super(0);}
|
||||
void test() {
|
||||
valueOf(0);
|
||||
valueOf(StaticMethod.bar());
|
||||
valueOf(StaticMethod.bar());
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,10 @@ public class MoveClassTest extends RefactoringTestCase {
|
||||
public void testUnusedImport() throws Exception {
|
||||
doTest("unusedImport", new String[]{"p2.F2"}, "p1");
|
||||
}
|
||||
|
||||
public void testQualifiedReferenceAfterFailedMethodConflictResolution() throws Exception {
|
||||
doTest("qualifiedRef", new String[]{"p1.Test"}, "p2");
|
||||
}
|
||||
|
||||
private void doTest(@NonNls String testName, @NonNls String[] classNames, @NonNls String newPackageName) throws Exception{
|
||||
String root = JavaTestUtil.getJavaTestDataPath() + "/refactoring/moveClass/" + testName;
|
||||
|
||||
Reference in New Issue
Block a user