Commit cd9e5f30 authored by caitpotter88's avatar caitpotter88 Committed by Commit bot

[builtins] make AsyncFunction constructor a subclass of Function

Corrects a small problem with the current implementation of the AsyncFunction
constructor.

See https://tc39.github.io/ecmascript-asyncawait/#async-function-constructor for
details.

BUG=v8:4483
R=littledan@chromium.org, adamk@chromium.org, jwolfe@igalia.com

Review-Url: https://codereview.chromium.org/2118653004
Cr-Commit-Position: refs/heads/master@{#37484}
parent 26625644
......@@ -2637,14 +2637,14 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
container, "AsyncFunction", JS_FUNCTION_TYPE, JSFunction::kSize,
async_function_prototype, Builtins::kAsyncFunctionConstructor,
kUseStrictFunctionMap);
async_function_constructor->set_prototype_or_initial_map(
native_context->sloppy_async_function_map());
async_function_constructor->shared()->DontAdaptArguments();
async_function_constructor->shared()->set_construct_stub(
*isolate->builtins()->AsyncFunctionConstructor());
async_function_constructor->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate, async_function_constructor,
Context::ASYNC_FUNCTION_FUNCTION_INDEX);
SetObjectPrototype(async_function_constructor,
isolate->function_function());
JSObject::AddProperty(
async_function_prototype, factory->constructor_string(),
......
......@@ -70,6 +70,15 @@ function assertEqualsAsync(expected, run, msg) {
assertEquals(undefined, this.AsyncFunction);
let AsyncFunction = (async function() {}).constructor;
// The AsyncFunction Constructor is the %AsyncFunction% intrinsic object and
// is a subclass of Function.
// (https://tc39.github.io/ecmascript-asyncawait/#async-function-constructor)
assertEquals(Object.getPrototypeOf(AsyncFunction), Function);
assertEquals(Object.getPrototypeOf(AsyncFunction.prototype),
Function.prototype);
assertTrue(async function() {} instanceof Function);
// Let functionPrototype be the intrinsic object %AsyncFunctionPrototype%.
async function asyncFunctionForProto() {}
assertEquals(AsyncFunction.prototype,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment