code: private void provideDefaultReturnType() {
      if (contents.getSourceNode() != null && contents.getSourceNode().isAsyncGeneratorFunction()) {
        // Set the return type of a generator function to:
        //   @return {!AsyncGenerator<?>}
        ObjectType generatorType = typeRegistry.getNativeObjectType(ASYNC_GENERATOR_TYPE);
        returnType =
            typeRegistry.createTemplatizedType(
                generatorType, typeRegistry.getNativeType(UNKNOWN_TYPE));
        return;
      } else if (contents.getSourceNode() != null && contents.getSourceNode().isGeneratorFunction()) {
        // Set the return type of a generator function to:
        //   @return {!Generator<?>}
        ObjectType generatorType = typeRegistry.getNativeObjectType(GENERATOR_TYPE);
        returnType =
            typeRegistry.createTemplatizedType(
                generatorType, typeRegistry.getNativeType(UNKNOWN_TYPE));
        return;
      }
  
      JSType inferredReturnType = typeRegistry.getNativeType(UNKNOWN_TYPE);
      if (!contents.mayHaveNonEmptyReturns()
          && !contents.mayHaveSingleThrow()
          && !contents.mayBeFromExterns()) {
        // Infer return types for non-generator functions.
        // We need to be extremely conservative about this, because of two
        // competing needs.
        // 1) If we infer the return type of f too widely, then we won't be able
        //    to assign f to other functions.
        // 2) If we infer the return type of f too narrowly, then we won't be
        //    able to override f in subclasses.
        // So we only infer in cases where the user doesn't expect to write
        // @return annotations--when it's very obvious that the function returns
        // nothing.
        inferredReturnType = typeRegistry.getNativeType(VOID_TYPE);
        returnTypeInferred = true;
      }
  
      if (contents.getSourceNode() != null && contents.getSourceNode().isAsyncFunction()) {
        // Set the return type of an async function:
        //   @return {!Promise<?>} or @return {!Promise<undefined>}
        ObjectType promiseType = typeRegistry.getNativeObjectType(PROMISE_TYPE);
        returnType = typeRegistry.createTemplatizedType(promiseType, inferredReturnType);
      } else {
        returnType = inferredReturnType;
      }
    }
docs: Sets the returnType for this function using very basic type inference.