mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix dfa when a notnull parameter is assigned to null
This commit is contained in:
+7
-2
@@ -268,9 +268,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return;
|
||||
}
|
||||
|
||||
setVariableState(var, getVariableState(var).withValue(value));
|
||||
setVariableState(var, withValueNullability(value, getVariableState(var).withValue(value)));
|
||||
if (value instanceof DfaTypeValue) {
|
||||
setVariableState(var, getVariableState(var).withNullability(((DfaTypeValue)value).getNullness()));
|
||||
DfaRelationValue dfaInstanceof = myFactory.getRelationFactory().createRelation(var, value, JavaTokenType.INSTANCEOF_KEYWORD, false);
|
||||
if (((DfaTypeValue)value).isNotNull()) {
|
||||
applyCondition(dfaInstanceof);
|
||||
@@ -293,6 +292,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
}
|
||||
}
|
||||
|
||||
private DfaVariableState withValueNullability(DfaValue value, DfaVariableState state) {
|
||||
if (value instanceof DfaTypeValue) return state.withNullability(((DfaTypeValue)value).getNullness());
|
||||
if (isNull(value)) return state.withNullability(Nullness.NULLABLE);
|
||||
return state;
|
||||
}
|
||||
|
||||
private DfaValue handleFlush(DfaVariableValue flushed, DfaValue value) {
|
||||
if (value instanceof DfaVariableValue && (value == flushed || myFactory.getVarFactory().getAllQualifiedBy(flushed).contains(value))) {
|
||||
Nullness nullability = isNotNull(value) ? Nullness.NOT_NULL : ((DfaVariableValue)value).getInherentNullability();
|
||||
|
||||
+11
@@ -2,6 +2,7 @@ import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
|
||||
/*
|
||||
@Nullable
|
||||
String findMessage(@NotNull Element element) {
|
||||
while (element != null) {
|
||||
@@ -23,6 +24,16 @@ class Test {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
void foo(@NotNull String param) {
|
||||
if (equals(3)) {
|
||||
param = null;
|
||||
}
|
||||
if (param != null) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user