mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
a consistent dfa treatment for plain fields assuming single-threaded context (IDEA-92380)
This commit is contained in:
@@ -1592,7 +1592,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
return myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, null, isCall);
|
||||
}
|
||||
|
||||
if (DfaUtil.isFinalField(var)) {
|
||||
if (DfaUtil.isFinalField(var) || DfaUtil.isPlainMutableField(var)) {
|
||||
DfaVariableValue qualifierValue = createChainedVariableValue(qualifier);
|
||||
if (qualifierValue != null) {
|
||||
return myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, qualifierValue, isCall || qualifierValue.isViaMethods());
|
||||
|
||||
@@ -135,7 +135,7 @@ public class DfaValueFactory {
|
||||
}
|
||||
}
|
||||
|
||||
if (isEffectivelyUnqualified(referenceExpression)) {
|
||||
if (!variable.hasModifierProperty(PsiModifier.VOLATILE) && isEffectivelyUnqualified(referenceExpression)) {
|
||||
return getVarFactory().createVariableValue(variable, referenceExpression.getType(), false, null, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public class DfaVariableValue extends DfaValue {
|
||||
|
||||
@Nullable
|
||||
public PsiType getVariableType() {
|
||||
return myVariable == null ? null : myVariable.getType();
|
||||
return myVarType;
|
||||
}
|
||||
|
||||
public boolean isNegated() {
|
||||
|
||||
+3
-3
@@ -32,11 +32,11 @@ class Foo {
|
||||
System.out.println(data.hashCode());
|
||||
}
|
||||
|
||||
void dontWarnWhenDoubleChecked(Foo f) {
|
||||
void warnWhenDoubleChecked(Foo f) {
|
||||
if (f.data == null) {
|
||||
return;
|
||||
}
|
||||
if (f.data == null) {
|
||||
if (<warning descr="Condition 'f.data == null' is always 'false'">f.data == null</warning>) {
|
||||
return;
|
||||
}
|
||||
System.out.println(f.data.hashCode());
|
||||
@@ -53,7 +53,7 @@ class Foo {
|
||||
}
|
||||
System.out.println(data.hashCode());
|
||||
}
|
||||
|
||||
|
||||
void dontWarnWhenDoubleChecked_This_WithMethodCall() {
|
||||
if (data == null) {
|
||||
return;
|
||||
|
||||
+2
-2
@@ -34,11 +34,11 @@ class Foo {
|
||||
System.out.println(data.hashCode());
|
||||
}
|
||||
|
||||
void dontWarnWhenDoubleChecked(Foo f) {
|
||||
void warnWhenDoubleChecked(Foo f) {
|
||||
if (f.data == null) {
|
||||
return;
|
||||
}
|
||||
if (f.data == null) {
|
||||
if (<warning descr="Condition 'f.data == null' is always 'false'">f.data == null</warning>) {
|
||||
return;
|
||||
}
|
||||
System.out.println(f.data.hashCode());
|
||||
|
||||
@@ -135,8 +135,8 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testConstantDoubleComparisons() { doTest(); }
|
||||
|
||||
public void _testMutableNullableFieldsTreatment() { doTest(); }
|
||||
public void _testMutableVolatileNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableVolatileNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableNotAnnotatedFieldsTreatment() { doTest(); }
|
||||
|
||||
public void testMethodCallFlushesField() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user