Bug 149477
Summary: | PromiseSubclass.resolve does not "cast" correctly | ||
---|---|---|---|
Product: | WebKit | Reporter: | Stefan Penner <stefan.penner> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Major | CC: | ashvayka, cdumez, ysuzuki |
Priority: | P2 | ||
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Stefan Penner
http://www.ecma-international.org/ecma-262/6.0/#sec-promise.resolve
the following lines of the spec text:
25.4.4.5.a
25.4.4.5.c
Indicate
class PromiseSubclass extends Promise { }
PromiseSubclass.resolve(Promise.resolve()).constructor === PromiseSubclass;
Unfortunately, today the following is true:
PromiseSubclass.resolve(Promise.resolve()).constructor === Promise;
Related patch to V8 -> https://codereview.chromium.org/1362773002
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Yusuke Suzuki
This is because the current Promise cannot be subclassible.
We can fix this by using newTarget in C++ Promise constructor as a workaround.
But ideally, this should be fixed by moving Promise to JS implemented constructor.
Alexey Shvayka
Promise subclassing was implemented in https://trac.webkit.org/changeset/191276.
Tests:
JSTests/es6/Promise_is_subclassable_*.js
JSTests/stress/derived-promise-constructor-*.js
*** This bug has been marked as a duplicate of bug 149380 ***