Bug 149477 - PromiseSubclass.resolve does not "cast" correctly
Summary: PromiseSubclass.resolve does not "cast" correctly
Status: RESOLVED DUPLICATE of bug 149380
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Major
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-22 15:21 PDT by Stefan Penner
Modified: 2020-04-03 11:04 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Penner 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
Comment 1 Yusuke Suzuki 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.
Comment 2 Alexey Shvayka 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 ***