Index: src/js/promise.js |
diff --git a/src/js/promise.js b/src/js/promise.js |
index a165817b7160ec3798f34e01917f5f4a8467a27b..6fc8728562c03f4e5def5bc4d3dcc72088b90b75 100644 |
--- a/src/js/promise.js |
+++ b/src/js/promise.js |
@@ -317,13 +317,13 @@ function PromiseCatch(onReject) { |
function PromiseCast(x) { |
if (!IS_RECEIVER(this)) { |
- throw MakeTypeError(kCalledOnNonObject, PromiseCast); |
- } |
- if (IsPromise(x) && x.constructor === this) { |
- return x; |
- } else { |
- return new this(function(resolve, reject) { resolve(x) }); |
+ throw MakeTypeError(kCalledOnNonObject, "Promise.resolve"); |
} |
+ if (IsPromise(x) && x.constructor === this) return x; |
+ |
+ var promiseCapability = NewPromiseCapability(this); |
+ var resolveResult = %_Call(promiseCapability.resolve, UNDEFINED, x); |
+ return promiseCapability.promise; |
} |
function PromiseAll(iterable) { |