private void visitImplicitReturnExpression ( NodeTraversal t , Node exprNode ) { Node enclosingFunction = t . getEnclosingFunction ( ) ; JSType jsType = getJSType ( enclosingFunction ) ; if ( jsType . isFunctionType ( ) ) { FunctionType functionType = jsType . toMaybeFunctionType ( ) ; JSType expectedReturnType = functionType . getReturnType ( ) ; // if no return type is specified, undefined must be returned // (it's a void function) if ( expectedReturnType == null ) { expectedReturnType = getNativeType ( VOID_TYPE ) ; } else if ( enclosingFunction . isAsyncFunction ( ) ) { // Unwrap the async function's declared return type. expectedReturnType = Promises . createAsyncReturnableType ( typeRegistry , expectedReturnType ) ; } // Fetch the returned value's type JSType actualReturnType = getJSType ( exprNode ) ; validator . expectCanAssignTo ( exprNode , actualReturnType , expectedReturnType , "inconsistent return type" ) ; } }
Visits an arrow function expression body .