Bug 149477

Summary: PromiseSubclass.resolve does not "cast" correctly
Product: WebKit Reporter: Stefan Penner <stefan.penner>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Major CC: ashvayka, cdumez, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Stefan Penner
Reported 2015-09-22 15:21:39 PDT
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
Yusuke Suzuki
Comment 1 2015-09-23 00:13:55 PDT
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
Comment 2 2020-04-03 11:04:04 PDT
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 ***
Note You need to log in before you can comment on or make changes to this bug.