code: @Nullable
    private JSType getExplicitReturnTypeIfExpected(Node scopeRoot) {
      if (!scopeRoot.isFunction()) {
        // Nothing to do in a global/module/block scope.
        return null;
      }
      FunctionType scopeType = JSType.toMaybeFunctionType(scopeRoot.getJSType());
  
      if (scopeType == null) {
        return null;
      }
  
      if (isEmptyFunction(scopeRoot)) {
        return null;
      }
  
      if (scopeType.isConstructor()) {
        return null;
      }
  
      JSType returnType = scopeType.getReturnType();
  
      if (returnType == null) {
        return null;
      }
  
      if (scopeRoot.isAsyncFunction()) {
        // Unwrap the declared return type (e.g. "!Promise<number>" becomes "number")
        returnType = Promises.getTemplateTypeOfThenable(compiler.getTypeRegistry(), returnType);
      }
  
      if (!isVoidOrUnknown(returnType)) {
        return returnType;
      }
  
      return null;
    }
docs: Determines if the given scope should explicitly return. All functions
  with non-void or non-unknown return types must have explicit returns.
  
  Exception: Constructors which specifically specify a return type are
  used to allow invocation without requiring the "new" keyword. They
  have an implicit return type. See unit tests.
  
  @return If a return type is expected, returns it. Otherwise, returns null.