Skip to content

Commit

Permalink
Fix throwing in init(resolver:) => warning
Browse files Browse the repository at this point in the history
The Resolver deallocated pending, so it led to the pending promise warning.

Aside: this of course means that we don’t warn for pending Guarantees or AnyPromises.

Fixes #799
  • Loading branch information
mxcl committed Feb 27, 2018
1 parent 6fd7675 commit 660c913
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions PromiseKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 6.1.2;
CURRENT_PROJECT_VERSION = 6.2.0;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -884,7 +884,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 6.1.2;
CURRENT_PROJECT_VERSION = 6.2.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down
5 changes: 3 additions & 2 deletions Sources/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ public class Promise<T>: Thenable, CatchMixin {
/// Initialize a new promise that can be resolved with the provided `Resolver`.
public init(resolver body: (Resolver<T>) throws -> Void) {
box = EmptyBox()
let resolver = Resolver(box)
do {
try body(Resolver(box))
try body(resolver)
} catch {
box.seal(.rejected(error))
resolver.reject(error)
}
}

Expand Down

0 comments on commit 660c913

Please sign in to comment.