private void checkForHosedThisReferences ( Node function , JSDocInfo docInfo , final Name name ) { // A function is getting collapsed. Make sure that if it refers to "this", // it must be a constructor, interface, record, arrow function, or documented with @this. boolean isAllowedToReferenceThis = ( docInfo != null && ( docInfo . isConstructorOrInterface ( ) || docInfo . hasThisType ( ) ) ) || function . isArrowFunction ( ) ; if ( ! isAllowedToReferenceThis ) { NodeTraversal . traverse ( compiler , function . getLastChild ( ) , new NodeTraversal . AbstractShallowCallback ( ) { @ Override public void visit ( NodeTraversal t , Node n , Node parent ) { if ( n . isThis ( ) ) { compiler . report ( JSError . make ( n , UNSAFE_THIS , name . getFullName ( ) ) ) ; } } } ) ; } }
Warns about any references to this in the given FUNCTION . The function is getting collapsed so the references will change .