Skip to content

Commit

Permalink
Automated g4 rollback of changelist 236682513.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breakages

*** Original change description ***

Deletes an unnecessary branch in `NodeUtil::checkForStateChangeHelper`.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=236890168
  • Loading branch information
nreid260 authored and blickly committed Mar 6, 2019
1 parent 967a689 commit e0cd8e2
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/com/google/javascript/jscomp/NodeUtil.java
Expand Up @@ -1154,6 +1154,18 @@ private static boolean checkForStateChangeHelper(
return true;

case OBJECTLIT:
if (checkForNewObjects) {
return true;
}
for (Node key = n.getFirstChild(); key != null; key = key.getNext()) {
for (Node c = key.getFirstChild(); c != null; c = c.getNext()) {
if (checkForStateChangeHelper(c, checkForNewObjects, compiler)) {
return true;
}
}
}
return false;

case ARRAYLIT:
case REGEXP:
if (checkForNewObjects) {
Expand All @@ -1162,18 +1174,11 @@ private static boolean checkForStateChangeHelper(
break;

case SPREAD:
Node parent = n.getParent();
if (parent.isObjectLit()) {
break; // Object spread is assumed side-effect free despite getters.
} else if (parent.isArrayLit() || parent.isCall()) {
if (!n.getOnlyChild().isArrayLit()) {
// If spreading anything other than an array-lit, in the absence of any other
// information, we have to assume is going to invoke invoke a stateful generator or the
// like.
return true;
}
} else {
throw new IllegalStateException("Unexpected parent of SPREAD: " + parent.toStringTree());
Node expr = n.getOnlyChild();
if (!expr.isArrayLit()) {
// Anything other than an array, in the absense of any other information,
// we have to assume is going to invoke invoke a stateful generator or the like.
return true;
}
break;

Expand Down

0 comments on commit e0cd8e2

Please sign in to comment.