When rewriting, mark newly constructed "this" nodes as non-indexable.
@@ -159,6 +159,7 @@ public class Es6RewriteArrowFunction implements NodeTraversal.Callback, HotSwapC
Node name = IR.name(THIS_VAR);
Node thisVar = IR.constNode(name, IR.thisNode());
thisVar.useSourceInfoIfMissingFromForTree(scopeBody);
+ makeTreeNonIndexable(thisVar);
if (thisContext.lastSuperStatement == null) {
scopeBody.addChildToFront(thisVar);
} else {
@@ -171,6 +172,13 @@ public class Es6RewriteArrowFunction implements NodeTraversal.Callback, HotSwapC
}
}
+ private void makeTreeNonIndexable(Node n) {
+ n.makeNonIndexable();
+ for (Node child : n.children()) {
+ makeTreeNonIndexable(child);
+ }
+ }
+
private static class UpdateThisAndArgumentsReferences implements NodeTraversal.Callback {
private boolean changedThis = false;
private boolean changedArguments = false;
@@ -184,6 +192,7 @@ public class Es6RewriteArrowFunction implements NodeTraversal.Callback, HotSwapC
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isThis()) {
Node name = IR.name(THIS_VAR).srcref(n);
+ name.makeNonIndexable();
if (compiler.getOptions().preservesDetailedSourceInfo()) {
name.setOriginalName("this");
}
