mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
dfa analysis should be aware that super calls may change fields (IDEA-102126)
This commit is contained in:
@@ -159,8 +159,8 @@ public class DfaValueFactory {
|
||||
if (qualifier == null) {
|
||||
return true;
|
||||
}
|
||||
if (qualifier instanceof PsiThisExpression){
|
||||
final PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)qualifier).getQualifier();
|
||||
if (qualifier instanceof PsiQualifiedExpression) { //this or super
|
||||
final PsiJavaCodeReferenceElement thisQualifier = ((PsiQualifiedExpression)qualifier).getQualifier();
|
||||
if (thisQualifier == null) return true;
|
||||
final PsiClass innerMostClass = PsiTreeUtil.getParentOfType(refExpression, PsiClass.class);
|
||||
if (innerMostClass == thisQualifier.resolve()) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
class Base {
|
||||
void foo() {}
|
||||
void bar() { foo(); }
|
||||
}
|
||||
|
||||
class Test extends Base {
|
||||
private String string;
|
||||
|
||||
void foo() {
|
||||
string = "";
|
||||
}
|
||||
|
||||
protected void bar() {
|
||||
string = null;
|
||||
super.bar();
|
||||
|
||||
if (string != null)
|
||||
super.bar();
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testMutableNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableVolatileNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableNotAnnotatedFieldsTreatment() { doTest(); }
|
||||
public void testSuperCallMayChangeFields() { doTest(); }
|
||||
|
||||
public void testMethodCallFlushesField() { doTest(); }
|
||||
public void testUnknownFloatMayBeNaN() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user