diff --git a/PromiseKit.podspec b/PromiseKit.podspec index a4a0f26fa..a078dbb3d 100644 --- a/PromiseKit.podspec +++ b/PromiseKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "PromiseKit" - s.version = '8.1.1' + s.version = '8.1.2' s.source = { :git => "https://github.com/mxcl/#{s.name}.git", diff --git a/PromiseKit.xcodeproj/project.pbxproj b/PromiseKit.xcodeproj/project.pbxproj index 6361b1800..fe64f56ec 100644 --- a/PromiseKit.xcodeproj/project.pbxproj +++ b/PromiseKit.xcodeproj/project.pbxproj @@ -946,7 +946,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 8.1.1; + CURRENT_PROJECT_VERSION = 8.1.2; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1008,7 +1008,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 8.1.1; + CURRENT_PROJECT_VERSION = 8.1.2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; diff --git a/Sources/Async.swift b/Sources/Async.swift index dbfc34457..b4b672c4c 100644 --- a/Sources/Async.swift +++ b/Sources/Async.swift @@ -17,7 +17,7 @@ public extension Promise { try await withCheckedThrowingContinuation { continuation in done { value in continuation.resume(returning: value) - }.catch { error in + }.catch(policy: .allErrors) { error in continuation.resume(throwing: error) } } diff --git a/Tests/CorePromise/AsyncTests.swift b/Tests/CorePromise/AsyncTests.swift index fa1dd61ac..345c5e32e 100644 --- a/Tests/CorePromise/AsyncTests.swift +++ b/Tests/CorePromise/AsyncTests.swift @@ -94,5 +94,55 @@ class AsyncTests: XCTestCase { } #endif + + #if swift(>=5.5) + #if canImport(_Concurrency) + @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) + func testAsyncPromiseCancel() async throws { + do { + let p = after(seconds: 0).done { _ in + throw LocalError.cancel + }.done { + XCTFail() + } + p.catch { _ in + XCTFail() + } + try await p.async() + XCTAssert(false) + } catch { + guard let cancellableError = error as? CancellableError else { return XCTFail("Unexpected error type") } + XCTAssertTrue(cancellableError.isCancelled) + } + } + + @available(iOS, deprecated: 13.0) + @available(macOS, deprecated: 10.15) + @available(tvOS, deprecated: 13.0) + @available(watchOS, deprecated: 6.0) + func testAsyncPromiseCancel() { + + } + #else + func testAsyncPromiseCancel() { + + } + #endif + #else + func testAsyncPromiseCancel() { + + } + #endif } +private enum LocalError: CancellableError { + case notCancel + case cancel + + var isCancelled: Bool { + switch self { + case .notCancel: return false + case .cancel: return true + } + } +}