Compare commits

..

No commits in common. "fix-NSError.isCancelled" and "master" have entirely different histories.

8 changed files with 28 additions and 44 deletions

View File

@ -620,7 +620,7 @@
6399A3721D595D9100D65233 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1200;
LastUpgradeCheck = 1100;
TargetAttributes = {
630019011D596292003B4E30 = {
LastSwiftMigration = 1100;
@ -815,12 +815,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
SWIFT_INSTALL_OBJC_HEADER = NO;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
};
@ -828,12 +828,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
SWIFT_INSTALL_OBJC_HEADER = NO;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
};
name = Release;
};
@ -925,7 +925,6 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -948,7 +947,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_DYLIB_INSTALL_NAME = "@rpath";
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = YES;
@ -959,7 +958,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
@ -987,7 +986,6 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -1008,7 +1006,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_DYLIB_INSTALL_NAME = "@rpath";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = org.promisekit;
@ -1017,7 +1015,7 @@
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos watchsimulator iphonesimulator watchos iphoneos";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -29,6 +29,15 @@
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63B0AC561D595E1B00FA21D9"
BuildableName = "PromiseKit.framework"
BlueprintName = "PromiseKit"
ReferencedContainer = "container:PromiseKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"

View File

@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import <dispatch/dispatch.h>
#import <PromiseKit/fwd.h>
#import "fwd.h"
/// INTERNAL DO NOT USE
@class __AnyPromise;

View File

@ -83,10 +83,9 @@ extension Error {
} catch CocoaError.userCancelled {
return true
} catch {
#if canImport(StoreKit)
let domain = (error as AnyObject).value(forKey: "domain") as? String
let code = (error as AnyObject).value(forKey: "code") as? Int
return ("SKErrorDomain", 2) == (domain, code)
#if os(macOS) || os(iOS) || os(tvOS)
let pair = { ($0.domain, $0.code) }(error as NSError)
return ("SKErrorDomain", 2) == pair
#else
return false
#endif

View File

@ -1,5 +1,5 @@
#import <PromiseKit/fwd.h>
#import <PromiseKit/AnyPromise.h>
#import "fwd.h"
#import "AnyPromise.h"
#import <Foundation/NSObjCRuntime.h> // `FOUNDATION_EXPORT`

View File

@ -139,7 +139,7 @@ public func when<It: IteratorProtocol>(fulfilled promiseIterator: It, concurrent
}
var generator = promiseIterator
let root = Promise<[It.Element.T]>.pending()
var root = Promise<[It.Element.T]>.pending()
var pendingPromises = 0
var promises: [It.Element] = []
@ -158,7 +158,9 @@ public func when<It: IteratorProtocol>(fulfilled promiseIterator: It, concurrent
barrier.sync(flags: .barrier) {
guard let next = generator.next() else { return }
promise = next
pendingPromises += 1
promises.append(next)
}

View File

@ -2,10 +2,6 @@ import Foundation
import PromiseKit
import XCTest
#if canImport(StoreKit)
import StoreKit
#endif
class CancellationTests: XCTestCase {
func testCancellation() {
let ex1 = expectation(description: "")
@ -99,25 +95,6 @@ class CancellationTests: XCTestCase {
waitForExpectations(timeout: 1)
}
func testDoesntCrashSwift() {
// Previously exposed a bridging crash in Swift
// NOTE nobody was brave enough or diligent enough to report this to Apple :{
XCTAssertFalse(NSError().isCancelled)
#if canImport(StoreKit)
do {
let err = SKError(.paymentCancelled)
XCTAssertTrue(err.isCancelled)
throw err
} catch {
XCTAssertTrue(error.isCancelled)
}
XCTAssertFalse(SKError(.clientInvalid).isCancelled)
#endif
}
#if swift(>=3.2)
func testIsCancelled() {
XCTAssertTrue(PMKError.cancelled.isCancelled)

View File

@ -18,7 +18,6 @@ extension CancellationTests {
// to regenerate.
static let __allTests__CancellationTests = [
("testCancellation", testCancellation),
("testDoesntCrashSwift", testDoesntCrashSwift),
("testFoundationBridging1", testFoundationBridging1),
("testFoundationBridging2", testFoundationBridging2),
("testIsCancelled", testIsCancelled),