Skip to content

Commit 6bd1cff

Browse files
12wrigjacopybara-github
authored andcommitted
Some small code clarity improvements to RewriteCallerCodeLocation.
PiperOrigin-RevId: 693528083
1 parent d9916a3 commit 6bd1cff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/com/google/javascript/jscomp/RewriteCallerCodeLocation.java

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.javascript.jscomp;
1818

19+
import static com.google.common.base.Preconditions.checkState;
20+
1921
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
2022
import com.google.javascript.rhino.IR;
2123
import com.google.javascript.rhino.Node;
@@ -94,6 +96,7 @@ private class FindCallerLocationFunctions extends AbstractPostOrderCallback {
9496
public void visit(NodeTraversal t, Node n, Node parent) {
9597
if (isGoogCallerLocationMisused(n, parent)) {
9698
compiler.report(JSError.make(parent.getParent(), JSC_CALLER_LOCATION_MISUSE_ERROR));
99+
return;
97100
}
98101

99102
if (n.isParamList()) {
@@ -137,6 +140,8 @@ private boolean isGoogCallerLocationMisused(Node n, Node parent) {
137140
}
138141

139142
if (n.getSourceFileName().contains("javascript/closure/base.js")) {
143+
// This is the definition of the debug build runtime implementation of goog.callerLocation.
144+
// This is not a misuse.
140145
return false;
141146
}
142147

@@ -157,6 +162,7 @@ private boolean isGoogCallerLocationMisused(Node n, Node parent) {
157162
* @param n param list node
158163
*/
159164
private void visitParamListAndAddCallerLocationFunctionNames(Node n, NodeTraversal t) {
165+
checkState(n.isParamList(), n);
160166
// function foo(<params>) ...
161167
// Each item in <params> is scanned for having a default value.
162168
// If there exists a default value, check if it is `goog.callerLocation`.

0 commit comments

Comments
 (0)