mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline parameter: reject inlining same final field on different objects
GitOrigin-RevId: d76451b71ff470adf6897c679dc6a83ecc241c72
This commit is contained in:
committed by
intellij-monorepo-bot
parent
986ac7d7fc
commit
5eb49a4db7
@@ -266,7 +266,10 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
|
||||
final PsiField field1 = getReferencedFinalField(expr1);
|
||||
final PsiField field2 = getReferencedFinalField(expr2);
|
||||
if (field1 != null && field1 == field2) {
|
||||
return true;
|
||||
PsiExpression q1 = ((PsiReferenceExpression)expr1).getQualifierExpression();
|
||||
PsiExpression q2 = ((PsiReferenceExpression)expr2).getQualifierExpression();
|
||||
return q1 == null && q2 == null ||
|
||||
q1 != null && q2 != null && PsiEquivalenceUtil.areElementsEquivalent(q1, q2);
|
||||
}
|
||||
Object value1 = JavaPsiFacade.getInstance(expr1.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr1);
|
||||
Object value2 = JavaPsiFacade.getInstance(expr2.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr2);
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
public class Subject {
|
||||
private int myInt;
|
||||
private int t;
|
||||
|
||||
public void wp(int <caret>p) {
|
||||
myInt += p;
|
||||
}
|
||||
|
||||
void foo(Subject s) {
|
||||
wp(s.t);
|
||||
wp(t);
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,10 @@ public class InlineParameterTest extends LightRefactoringTestCase {
|
||||
doTestCannotFindInitializer();
|
||||
}
|
||||
|
||||
public void testRefSameFinalFieldOtherObject() {
|
||||
doTestCannotFindInitializer();
|
||||
}
|
||||
|
||||
public void testRef2ConstantsWithTheSameValue() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user