Chromium Code Reviews| Index: src/js/promise.js |
| diff --git a/src/js/promise.js b/src/js/promise.js |
| index de9597942c010f52d6dd996fc5faac2000b628ec..041b598764f7b7733284a9a4fc512b6efff2ac2b 100644 |
| --- a/src/js/promise.js |
| +++ b/src/js/promise.js |
| @@ -354,11 +354,15 @@ function PromiseThen(onResolve, onReject) { |
| // Combinators. |
| function PromiseCast(x) { |
| - if (IsPromise(x) && x.constructor === this) { |
| - return x; |
| - } else { |
| - return new this(function(resolve) { resolve(x) }); |
| + if (!IS_RECEIVER(this)) { |
| + throw MakeTypeError(kCalledOnNonObject, "Promise.resolve"); |
| } |
| + |
| + if (IsPromise(x) && x.constructor === this) return x; |
| + |
| + var promiseCapability = NewPromiseCapability(this); |
|
caitp (gmail)
2016/01/04 14:52:11
Technically, the assertions added in NewPromiseCap
Dan Ehrenberg
2016/01/04 18:04:20
Yep, I agree. Still looks good to me. The trybot j
|
| + var resolveResult = promiseCapability.resolve(x); |
| + return promiseCapability.promise; |
| } |
| function PromiseAll(iterable) { |