IDEA-44118 Possible NPE from @Nullable isn't flagged in synchronized() statement

This commit is contained in:
peter
2012-10-29 12:57:21 +01:00
parent 1ff583bd4a
commit 1a28ca4230
3 changed files with 13 additions and 1 deletions
@@ -606,7 +606,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
PsiExpression lock = statement.getLockExpression();
if (lock != null) {
lock.accept(this);
addInstruction(new PopInstruction());
addInstruction(new FieldReferenceInstruction(lock, "Synchronized value"));
}
addInstruction(new FlushVariableInstruction(null));
@@ -0,0 +1,10 @@
import org.jetbrains.annotations.Nullable;
public class BrokenAlignment {
void test(@Nullable Object n) {
synchronized (<warning descr="Dereference of 'n' may produce 'java.lang.NullPointerException'">n</warning>) {
}
}
}
@@ -85,4 +85,6 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
public void testAssigningUnknownToNullable() throws Throwable { doTest(); }
public void testSynchronizingOnNullable() throws Throwable { doTest(); }
}