use of org.checkerframework.dataflow.cfg.node.Node in project error-prone by google.
the class NullnessPropagationTransfer method visitAssignment.
@Override
Nullness visitAssignment(AssignmentNode node, SubNodeValues inputs, LocalVariableUpdates updates) {
Nullness value = inputs.valueOfSubNode(node.getExpression());
Node target = node.getTarget();
if (target instanceof LocalVariableNode) {
updates.set((LocalVariableNode) target, value);
}
if (target instanceof ArrayAccessNode) {
setNonnullIfLocalVariable(updates, ((ArrayAccessNode) target).getArray());
}
if (target instanceof FieldAccessNode) {
FieldAccessNode fieldAccess = (FieldAccessNode) target;
ClassAndField targetField = tryGetFieldSymbol(target.getTree());
setReceiverNonnull(updates, fieldAccess.getReceiver(), targetField);
}
/*
* We propagate the value of the target to the value of the assignment expressions as a whole.
* We do this regardless of whether the target is a local variable. For example:
*
* String s = object.field = "foo"; // Now |s| is non-null.
*
* It's not clear to me that this is technically correct, but it works in practice with the
* bytecode generated by both javac and ecj.
*
* http://stackoverflow.com/q/12850676/28465
*/
return value;
}
Aggregations