diff --git a/projects/Closure/22/com/google/javascript/jscomp/CheckSideEffects.java b/projects/Closure/22/com/google/javascript/jscomp/CheckSideEffects.java index b9aa412..722d225 100644 --- a/projects/Closure/22/com/google/javascript/jscomp/CheckSideEffects.java +++ b/projects/Closure/22/com/google/javascript/jscomp/CheckSideEffects.java @@ -98,44 +98,20 @@ public void visit(NodeTraversal t, Node n, Node parent) { // Do not try to remove a block or an expr result. We already handle // these cases when we visit the child, and the peephole passes will // fix up the tree in more clever ways when these are removed. - if (parent.getType() == Token.COMMA) { - Node gramps = parent.getParent(); - if (gramps.isCall() && parent == gramps.getFirstChild()) { - if (n == parent.getFirstChild() && parent.getChildCount() == 2 && n.getNext().isName() && "eval".equals(n.getNext().getString())) { + if (n.isExprResult() || n.isBlock()) { return; - } } // This no-op statement was there so that JSDoc information could // be attached to the name. This check should not complain about it. - if (n == parent.getLastChild()) { - for (Node an : parent.getAncestors()) { - int ancestorType = an.getType(); - if (ancestorType == Token.COMMA) - continue; - if (ancestorType != Token.EXPR_RESULT && ancestorType != Token.BLOCK) - return; - else - break; - } - } - } else if (parent.getType() != Token.EXPR_RESULT && parent.getType() != Token.BLOCK) { - if (parent.getType() == Token.FOR && parent.getChildCount() == 4 && (n == parent.getFirstChild() || - n == parent.getFirstChild().getNext().getNext())) { - } else { + if (n.isQualifiedName() && n.getJSDocInfo() != null) { return; - } } boolean isResultUsed = NodeUtil.isExpressionResultUsed(n); boolean isSimpleOp = NodeUtil.isSimpleOperatorType(n.getType()); if (!isResultUsed && (isSimpleOp || !NodeUtil.mayHaveSideEffects(n, t.getCompiler()))) { - if (n.isQualifiedName() && n.getJSDocInfo() != null) { - return; - } else if (n.isExprResult()) { - return; - } String msg = "This code lacks side-effects. Is there a bug?"; if (n.isString()) { msg = "Is there a missing '+' on the previous line?";