private void pullDestructuringOutOfParams ( Node paramList , Node function ) { Node insertSpot = null ; Node body = function . getLastChild ( ) ; int i = 0 ; Node next = null ; for ( Node param = paramList . getFirstChild ( ) ; param != null ; param = next , i ++ ) { next = param . getNext ( ) ; if ( param . isDefaultValue ( ) ) { Node nameOrPattern = param . removeFirstChild ( ) ; // We'll be cloning nameOrPattern below, and we don't want to clone the JSDoc info with it JSDocInfo jsDoc = nameOrPattern . getJSDocInfo ( ) ; nameOrPattern . setJSDocInfo ( null ) ; Node defaultValue = param . removeFirstChild ( ) ; Node newParam ; // Treat name=undefined (and equivalent) as if it was just name. There // is no need to generate a (name===void 0?void 0:name) statement for // such arguments. boolean isNoop = false ; if ( ! nameOrPattern . isName ( ) ) { // Do not try to optimize unless nameOrPattern is a simple name. } else if ( defaultValue . isName ( ) ) { isNoop = "undefined" . equals ( defaultValue . getString ( ) ) ; } else if ( defaultValue . isVoid ( ) ) { // Any kind of 'void literal' is fine, but 'void fun()' or anything // else with side effects isn't. We're not trying to be particularly // smart here and treat 'void {}' for example as if it could cause side effects. isNoop = NodeUtil . isImmutableValue ( defaultValue . getFirstChild ( ) ) ; } if ( isNoop ) { newParam = nameOrPattern . cloneTree ( ) ; } else { newParam = nameOrPattern . isName ( ) ? nameOrPattern : astFactory . createName ( getTempVariableName ( ) , nameOrPattern . getJSType ( ) ) ; Node lhs = nameOrPattern . cloneTree ( ) ; Node rhs = defaultValueHook ( newParam . cloneTree ( ) , defaultValue ) ; Node newStatement = nameOrPattern . isName ( ) ? IR . exprResult ( astFactory . createAssign ( lhs , rhs ) ) : IR . var ( lhs , rhs ) ; newStatement . useSourceInfoIfMissingFromForTree ( param ) ; body . addChildAfter ( newStatement , insertSpot ) ; insertSpot = newStatement ; } paramList . replaceChild ( param , newParam ) ; newParam . setOptionalArg ( true ) ; newParam . setJSDocInfo ( jsDoc ) ; compiler . reportChangeToChangeScope ( function ) ; } else if ( param . isDestructuringPattern ( ) ) { insertSpot = replacePatternParamWithTempVar ( function , insertSpot , param , getTempVariableName ( ) ) ; compiler . reportChangeToChangeScope ( function ) ; } else if ( param . isRest ( ) && param . getFirstChild ( ) . isDestructuringPattern ( ) ) { insertSpot = replacePatternParamWithTempVar ( function , insertSpot , param . getFirstChild ( ) , getTempVariableName ( ) ) ; compiler . reportChangeToChangeScope ( function ) ; } } }
the parameter list contains a usage of OBJECT_REST .