public TransferResult visitAssignment()

in nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessPropagation.java [509:545]


  public TransferResult<Nullness, NullnessStore> visitAssignment(
      AssignmentNode node, TransferInput<Nullness, NullnessStore> input) {
    ReadableUpdates updates = new ReadableUpdates();
    Node rhs = node.getExpression();
    Nullness value = values(input).valueOfSubNode(rhs);
    Node target = node.getTarget();

    if (target instanceof LocalVariableNode
        && !castToNonNull(ASTHelpers.getType(target.getTree())).isPrimitive()) {
      LocalVariableNode localVariableNode = (LocalVariableNode) target;
      updates.set(localVariableNode, value);
      handleEnhancedForOverKeySet(localVariableNode, rhs, input, updates);
    }

    if (target instanceof ArrayAccessNode) {
      setNonnullIfAnalyzeable(updates, ((ArrayAccessNode) target).getArray());
    }

    if (target instanceof FieldAccessNode) {
      FieldAccessNode fieldAccessNode = (FieldAccessNode) target;
      Node receiver = fieldAccessNode.getReceiver();
      setNonnullIfAnalyzeable(updates, receiver);
      if (fieldAccessNode.getElement().getKind().equals(ElementKind.FIELD)
          && !castToNonNull(ASTHelpers.getType(target.getTree())).isPrimitive()) {
        if (receiver instanceof ThisNode || fieldAccessNode.isStatic()) {
          // Guaranteed to produce a valid access path, we call updates.set
          updates.set(fieldAccessNode, value);
        } else {
          // Might not be a valid access path, e.g. it might ultimately be rooted at (new Foo).f or
          // some other expression that's not a valid AP root.
          updates.tryAndSet(fieldAccessNode, value);
        }
      }
    }

    return updateRegularStore(value, input, updates);
  }