mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
volatile field's nullity shouldn't be used for dfa (IDEA-64696)
This commit is contained in:
+3
-1
@@ -92,7 +92,9 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
onAssigningToNotNullableVariable(instruction, runner);
|
||||
}
|
||||
}
|
||||
memState.setVarValue(var, dfaSource);
|
||||
if (!(psiVariable instanceof PsiField) || !psiVariable.hasModifierProperty(PsiModifier.VOLATILE)) {
|
||||
memState.setVarValue(var, dfaSource);
|
||||
}
|
||||
}
|
||||
|
||||
memState.push(dfaDest);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import javax.swing.*;
|
||||
|
||||
class Test {
|
||||
public void setObj(Object obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
obj = new Object();
|
||||
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Object o = obj;
|
||||
if (o != null) {
|
||||
System.out.println("x");
|
||||
}
|
||||
}
|
||||
});
|
||||
final Object u = new Object();
|
||||
if (<warning descr="Condition 'u != null' is always 'true'">u != null</warning>) {
|
||||
System.out.println("y");
|
||||
}
|
||||
obj = null;
|
||||
}
|
||||
|
||||
private volatile Object obj;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
class Test {
|
||||
public void setObj(Object obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
obj = new Object();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Object o = obj;
|
||||
if (<warning descr="Condition 'o != null' is always 'true'">o != null</warning>) {
|
||||
System.out.println("x");
|
||||
}
|
||||
}
|
||||
});
|
||||
obj = <warning descr="'null' is assigned to a variable that is annotated with @NotNull">null</warning>;
|
||||
}
|
||||
|
||||
@NotNull private volatile Object obj;
|
||||
}
|
||||
@@ -29,5 +29,7 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
|
||||
public void testTryInAnonymous() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousMethod() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousParameter() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousVolatile() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user