src/com/google/javascript/jscomp/TypeCheck.java
/**
   * Visits a NAME node.
   *
   * @param t The node traversal object that supplies context, such as the
   * scope chain to use in name lookups as well as error reporting.
   * @param n The node being visited.
   * @param parent The parent of the node n.
   * @return whether the node is typeable or not
   */
Visits a NAME node.
@param t The node traversal object that supplies context, such as the
scope chain to use in name lookups as well as error reporting.
@param n The node being visited.
@param parent The parent of the node n.
@return whether the node is typeable or not
Visits a NAME node . @param t The node traversal object that supplies context such as the scope chain to use in name lookups as well as error reporting . @param n The node being visited . @param parent The parent of the node n . @return whether the node is typeable or not
boolean visitName(NodeTraversal t, Node n, Node parent) {
    Token parentNodeType = parent.getToken();
    if (parentNodeType == Token.FUNCTION
        || parentNodeType == Token.CATCH
        || parentNodeType == Token.PARAM_LIST
        || NodeUtil.isNameDeclaration(parent)
        ) {
      return false;
    }
    if (NodeUtil.isEnhancedFor(parent) && parent.getFirstChild() == n) {
      return false;
    }
    JSType type = n.getJSType();
    if (type == null) {
      type = getNativeType(UNKNOWN_TYPE);
      TypedVar var = t.getTypedScope().getVar(n.getString());
      if (var != null) {
        JSType varType = var.getType();
        if (varType != null) {
          type = varType;
        }
      }
    }
    ensureTyped(n, type);
    return true;
  }
boolean visitName ( NodeTraversal t , Node n , Node parent ) { Token parentNodeType = parent . getToken ( ) ; if ( parentNodeType == Token . FUNCTION || parentNodeType == Token . CATCH || parentNodeType == Token . PARAM_LIST || NodeUtil . isNameDeclaration ( parent ) ) { return false ; } if ( NodeUtil . isEnhancedFor ( parent ) && parent . getFirstChild ( ) == n ) { return false ; } JSType type = n . getJSType ( ) ; if ( type == null ) { type = getNativeType ( UNKNOWN_TYPE ) ; TypedVar var = t . getTypedScope ( ) . getVar ( n . getString ( ) ) ; if ( var != null ) { JSType varType = var . getType ( ) ; if ( varType != null ) { type = varType ; } } } ensureTyped ( n , type ) ; return true ; }
Visits a NAME node.
Visits a NAME node .
// At this stage, we need to determine whether this is a leaf // node in an expression (which therefore needs to have a type // assigned for it) versus some other decorative node that we // can safely ignore.  Function names, arguments (children of PARAM_LIST nodes) and // variable declarations are ignored. // TODO(user): remove this short-circuiting in favor of a // pre order traversal of the FUNCTION, CATCH, PARAM_LIST and VAR nodes. // Not need to type first key in for-in or for-of.