Expect the type to be a AsyncGenerator or supertype of AsyncGenerator.
761509
void expectAsyncGeneratorSupertype(Node n, JSType type, String msg) {
    if (!getNativeType(ASYNC_GENERATOR_TYPE).isSubtypeOf(type)) {
      mismatch(n, msg, type, ASYNC_GENERATOR_TYPE);
    }
  }
1061044
def CallApiHandler(handler, args, token=None):
    """"""

    result = handler.Handle(args, token=token)

    expected_type = handler.result_type
    if expected_type is None:
      expected_type = None.__class__

    if result.__class__ != expected_type:
      raise UnexpectedResultTypeError(
          "Expected %s, but got %s." %
          (expected_type.__name__, result.__class__.__name__))

    return result
75582
def isgenerator(obj):
    '''  '''
    return isinstance(obj, GeneratorType) or (hasattr(obj, 'iterable') and
           isinstance(getattr(obj, 'iterable'), GeneratorType))
758223
function EventEmitter(isAsync) {
        if (isAsync === void 0) { isAsync = false; }
        var _this = _super.call(this) || this;
        _this.__isAsync = isAsync;
        return _this;
    }
271301
function promisify_cb_func_generic(result_transformer, cb_generator) {
    result_transformer = result_transformer || identity;

    var transformer = function (func_promise) {
        return function (/* ... */) {
            var args = arguments;
            return result_transformer(when(func_promise, function (func) {
                var d = when.defer();
                func.apply(null, append(args, cb_generator(d)));
                return d.promise;
            }));
        };
    };

    transformer.for_property = function (obj_promise, prop) {
        return function(/* ... */) {
            var args = arguments;
            return result_transformer(when(obj_promise, function (obj) {
                var d = when.defer();
                obj[prop].apply(obj, append(args, cb_generator(d)));
                return d.promise;
            }));
        };
    };

    return transformer;
}
316224
async function* streamToGenerator(stream) {
  let promise;

  stream.on('data', data => promise.resolve(data));
  stream.once('end', () => promise.resolve(null));

  stream.on('error', error => {
    stream.removeAllListeners();
    promise.reject(error);
  });

  while (true) {
    promise = defer();

    yield promise;
  }
}
839385
function AsyncComponent(options, loader) {
    this.options = options;
    this.loader = loader;
    this.id = guid++;
    this.children = [];

    // #[begin] reverse
    var reverseWalker = options.reverseWalker;
    if (reverseWalker) {
        var PlaceholderComponent = this.loader.placeholder;
        if (PlaceholderComponent) {
            this.children[0] = new PlaceholderComponent(options);
        }

        this._create();
        insertBefore(this.el, reverseWalker.target, reverseWalker.current);

        var me = this;
        this.loader.start(function (ComponentClass) {
            me.onload(ComponentClass);
        });
    }
    options.reverseWalker = null;
    // #[end]
}
1242623
def Type(expected, message="Not of type {}"):
    
    @wraps(Type)
    def built(value):
        if type(value) != expected:
            raise Error(message.format(expected.__name__))
        return value
    return built
314405
void expectSuperType(Node n, ObjectType superObject, ObjectType subObject) {
    FunctionType subCtor = subObject.getConstructor();
    ObjectType implicitProto = subObject.getImplicitPrototype();
    ObjectType declaredSuper =
        implicitProto == null ? null : implicitProto.getImplicitPrototype();
    if (declaredSuper != null && declaredSuper.isTemplatizedType()) {
      declaredSuper =
          declaredSuper.toMaybeTemplatizedType().getReferencedType();
    }
    if (declaredSuper != null
        && !(superObject instanceof UnknownType)
        && !declaredSuper.isEquivalentTo(superObject)) {
      if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
        registerMismatch(
            superObject,
            declaredSuper,
            report(JSError.make(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
      } else {
        mismatch(n, "mismatch in declaration of superclass type", superObject, declaredSuper);
      }

      // Correct the super type.
      if (!subCtor.hasCachedValues()) {
        subCtor.setPrototypeBasedOn(superObject);
      }
    }
  }
377107
function createPrimaryTypeChecker(type) {

    return createChainableChecker(function (data, dataName, componentName, fullDataName) {

        var dataValue = data[dataName];
        var dataType = getDataType(dataValue);

        if (dataType !== type) {
            throw new Error('[SAN ERROR] '
                + 'Invalid ' + componentName + ' data `' + fullDataName + '` of type'
                + '(' + dataType + ' supplied to ' + componentName + ', '
                + 'expected ' + type + ')'
            );
        }

    });

}
1275227
protected void pushReturnType(InvokeInstruction ins) {
        ConstantPoolGen cpg = getCPG();
        Type type = ins.getType(cpg);
        if (type.getType() != Const.T_VOID) {
            pushValue(type);
        }
    }
957229
def _async_callable(func):
    """"""
    if isinstance(func, types.CoroutineType):

        return func

    @functools.wraps(func)
    async def _async_def_wrapper(*args, **kwargs):
        """Wrap a a sync callable in an async def."""
        return func(*args, **kwargs)

    return _async_def_wrapper
621657
def syncify(*types):
    
    # Our asynchronous generators all are `RequestIter`, which already
    # provide a synchronous iterator variant, so we don't need to worry
    # about asyncgenfunction's here.
    for t in types:
        for name in dir(t):
            if not name.startswith('_') or name == '__call__':
                if inspect.iscoroutinefunction(getattr(t, name)):
                    _syncify_wrap(t, name)
619579
function generatorToPromise(fn) {
    if (typeof fn !== 'function') {
        throw Error('fn is not a function');
    }
    if (!isGenerator(fn)) {
        // assume it's Promise-based
        return fn;
    }
    return co.wrap(fn);
}
577895
@Override
    public <T extends ProcessingElement> T createPE(Class<T> type) {
        return super.createPE(type);
    }
942886
public static synchronized <T> T createNiceMockAndExpectNew(Class<T> type, Object... arguments) throws Exception {
        T mock = createNiceMock(type);
        IExpectationSetters<T> expectationSetters = expectNiceNew(type, arguments);
        if (expectationSetters != null) {
            expectationSetters.andReturn(mock);
        }
        return mock;
    }
650502
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;
    }
  }