Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1123)

Unified Diff: src/promise.js

Issue 1362773002: [es6] Align Promise.resolve with the spec (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove corresponding entry from patch262.status (that scenario is now passing) Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index b509e76e4a9d16c9a7ba1db080b1708236d38777..728a23157b1d8e747251cbfb5cee6dddef52a083 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -285,8 +285,11 @@ function PromiseThen(onResolve, onReject) {
// Combinators.
function PromiseCast(x) {
- // TODO(rossberg): cannot do better until we support @@create.
- return IsPromise(x) ? x : new this(function(resolve) { resolve(x) });
+ if (IsPromise(x) && x.constructor === this) {
+ return x;
+ } else {
+ return new this(function(resolve) { resolve(x) });
+ }
}
function PromiseAll(iterable) {
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698