16
16
17
17
package com .google .javascript .jscomp ;
18
18
19
+ import static com .google .common .base .Preconditions .checkState ;
20
+
19
21
import com .google .javascript .jscomp .NodeTraversal .AbstractPostOrderCallback ;
20
22
import com .google .javascript .rhino .IR ;
21
23
import com .google .javascript .rhino .Node ;
@@ -94,6 +96,7 @@ private class FindCallerLocationFunctions extends AbstractPostOrderCallback {
94
96
public void visit (NodeTraversal t , Node n , Node parent ) {
95
97
if (isGoogCallerLocationMisused (n , parent )) {
96
98
compiler .report (JSError .make (parent .getParent (), JSC_CALLER_LOCATION_MISUSE_ERROR ));
99
+ return ;
97
100
}
98
101
99
102
if (n .isParamList ()) {
@@ -137,6 +140,8 @@ private boolean isGoogCallerLocationMisused(Node n, Node parent) {
137
140
}
138
141
139
142
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.
140
145
return false ;
141
146
}
142
147
@@ -157,6 +162,7 @@ private boolean isGoogCallerLocationMisused(Node n, Node parent) {
157
162
* @param n param list node
158
163
*/
159
164
private void visitParamListAndAddCallerLocationFunctionNames (Node n , NodeTraversal t ) {
165
+ checkState (n .isParamList (), n );
160
166
// function foo(<params>) ...
161
167
// Each item in <params> is scanned for having a default value.
162
168
// If there exists a default value, check if it is `goog.callerLocation`.
0 commit comments