code: private boolean tryReplacingAliasingAssignment(Ref alias, Node aliasLhsNode) {
      // either VAR/CONST/LET or ASSIGN.
      Node assignment = aliasLhsNode.getParent();
      if (!NodeUtil.isNameDeclaration(assignment) && NodeUtil.isExpressionResultUsed(assignment)) {
        // e.g. don't change "if (alias = someVariable)" to "if (alias = null)"
        // TODO(lharker): instead replace the entire assignment with the RHS - "alias = x" becomes "x"
        return false;
      }
      Node aliasParent = alias.getNode().getParent();
      aliasParent.replaceChild(alias.getNode(), IR.nullNode());
      alias.name.removeRef(alias);
      codeChanged = true;
      compiler.reportChangeToEnclosingScope(aliasParent);
      return true;
    }
docs: Replaces the rhs of an aliasing assignment with null, unless the assignment result is used in a
  complex expression.