From a285bbc03874cfdf000b7b905e428c491fd497cd Mon Sep 17 00:00:00 2001 From: James Hurst Date: Mon, 1 Aug 2016 21:06:31 -0400 Subject: [PATCH 1/7] Changes for Xcode 8 beta 4 --- Result/Result.swift | 10 +++++----- Result/ResultProtocol.swift | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Result/Result.swift b/Result/Result.swift index 5ab9c48..842fc94 100644 --- a/Result/Result.swift +++ b/Result/Result.swift @@ -1,7 +1,7 @@ // Copyright (c) 2015 Rob Rix. All rights reserved. /// An enum representing either a failure with an explanatory error, or a success with a result value. -public enum Result: ResultProtocol, CustomStringConvertible, CustomDebugStringConvertible { +public enum Result: ResultProtocol, CustomStringConvertible, CustomDebugStringConvertible { case success(T) case failure(Error) @@ -157,8 +157,8 @@ public func `try`(_ function: String = #function, file: String = #file, line: In // MARK: - ErrorProtocolConvertible conformance extension NSError: ErrorProtocolConvertible { - public static func error(from error: ErrorProtocol) -> Self { - func cast(_ error: ErrorProtocol) -> T { + public static func error(from error: Swift.Error) -> Self { + func cast(_ error: Swift.Error) -> T { return error as! T } @@ -173,7 +173,7 @@ extension NSError: ErrorProtocolConvertible { /// This can be used to describe `Result`s where failures will never /// be generated. For example, `Result` describes a result that /// contains an `Int`eger and is guaranteed never to be a `Failure`. -public enum NoError: ErrorProtocol { } +public enum NoError: Swift.Error { } // MARK: - migration support extension Result { @@ -190,7 +190,7 @@ extension Result { extension NSError { @available(*, unavailable, renamed: "error(from:)") - public static func errorFromErrorType(_ error: ErrorProtocol) -> Self { + public static func errorFromErrorType(_ error: Swift.Error) -> Self { fatalError() } } diff --git a/Result/ResultProtocol.swift b/Result/ResultProtocol.swift index f4b0d28..ae33ffd 100644 --- a/Result/ResultProtocol.swift +++ b/Result/ResultProtocol.swift @@ -3,7 +3,7 @@ /// A type that can represent either failure with an error or success with a result value. public protocol ResultProtocol { associatedtype Value - associatedtype Error: ErrorProtocol + associatedtype Error: Swift.Error /// Constructs a successful result wrapping a `value`. init(value: Value) @@ -82,8 +82,8 @@ public extension ResultProtocol { } /// Protocol used to constrain `tryMap` to `Result`s with compatible `Error`s. -public protocol ErrorProtocolConvertible: ErrorProtocol { - static func error(from error: ErrorProtocol) -> Self +public protocol ErrorProtocolConvertible: Swift.Error { + static func error(from error: Swift.Error) -> Self } public extension ResultProtocol where Error: ErrorProtocolConvertible { @@ -135,9 +135,9 @@ public func >>- (result: T, transform: @noescape (T.Value /// Returns `true` if `left` and `right` are both `Success`es and their values are equal, or if `left` and `right` are both `Failure`s and their errors are equal. public func == (left: T, right: T) -> Bool { - if let left = left.value, right = right.value { + if let left = left.value, let right = right.value { return left == right - } else if let left = left.error, right = right.error { + } else if let left = left.error, let right = right.error { return left == right } return false @@ -163,7 +163,7 @@ public func ?? (left: T, right: @autoclosure () -> T) -> T { public typealias ResultType = ResultProtocol @available(*, unavailable, renamed: "ErrorProtocol") -public typealias ResultErrorType = ErrorProtocol +public typealias ResultErrorType = Swift.Error @available(*, unavailable, renamed: "ErrorProtocolConvertible") public typealias ErrorTypeConvertible = ErrorProtocolConvertible @@ -177,7 +177,7 @@ extension ResultProtocol { extension ErrorProtocolConvertible { @available(*, unavailable, renamed: "error(from:)") - public static func errorFromErrorType(_ error: ErrorProtocol) -> Self { + public static func errorFromErrorType(_ error: Swift.Error) -> Self { fatalError() } } From cdf310de1a1258fc2b3f20e02b85438ba11695da Mon Sep 17 00:00:00 2001 From: James Hurst Date: Tue, 2 Aug 2016 19:00:16 -0400 Subject: [PATCH 2/7] Updated unit tests for Xcode 8 beta 4 --- Tests/Result/ResultTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Result/ResultTests.swift b/Tests/Result/ResultTests.swift index 2989f9d..071f980 100644 --- a/Tests/Result/ResultTests.swift +++ b/Tests/Result/ResultTests.swift @@ -100,7 +100,7 @@ final class ResultTests: XCTestCase { } func testRecoverProducesRightForLeftFailure() { - struct Error: ErrorProtocol {} + struct Error: Swift.Error {} let left = Result.failure(Error()) XCTAssertEqual(left.recover("right"), "right") @@ -116,7 +116,7 @@ final class ResultTests: XCTestCase { } func testRecoverWithProducesRightSuccessForLeftFailureAndRightSuccess() { - struct Error: ErrorProtocol {} + struct Error: Swift.Error {} let left = Result.failure(Error()) let right = Result.success("right") @@ -125,7 +125,7 @@ final class ResultTests: XCTestCase { } func testRecoverWithProducesRightFailureForLeftFailureAndRightFailure() { - enum Error: ErrorProtocol { case left, right } + enum Error: Swift.Error { case left, right } let left = Result.failure(.left) let right = Result.failure(.right) @@ -220,7 +220,7 @@ func attempt(_ value: T, succeed: Bool, error: NSErrorPointer) -> T? { #endif func tryIsSuccess(_ text: String?) throws -> String { - guard let text = text where text == "success" else { + guard let text = text, text == "success" else { throw error } From 9c7ad7bece60bfe181d62110ca743b23536f26a2 Mon Sep 17 00:00:00 2001 From: James Hurst Date: Wed, 3 Aug 2016 22:32:32 -0400 Subject: [PATCH 3/7] Updated .swift-version to 3.0-PREVIEW-3 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 1fc762a..dc94365 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0-PREVIEW-2 +3.0-PREVIEW-3 From 29beab430e1511d66fa634f306b1a43cd6c8770d Mon Sep 17 00:00:00 2001 From: James Hurst Date: Wed, 3 Aug 2016 22:59:05 -0400 Subject: [PATCH 4/7] Updated .swift-version to DEVELOPMENT-SNAPSHOT-2016-07-29-a --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index dc94365..be77e20 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0-PREVIEW-3 +DEVELOPMENT-SNAPSHOT-2016-07-29-a From db09c28f4004a7b0d68e9b4531a6e1b574f3e7da Mon Sep 17 00:00:00 2001 From: James Hurst Date: Wed, 3 Aug 2016 23:05:28 -0400 Subject: [PATCH 5/7] Renamed Tests/Result to Tests/ResultTests --- Tests/{Result => ResultTests}/Info.plist | 0 Tests/{Result => ResultTests}/ResultTests.swift | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Tests/{Result => ResultTests}/Info.plist (100%) rename Tests/{Result => ResultTests}/ResultTests.swift (100%) diff --git a/Tests/Result/Info.plist b/Tests/ResultTests/Info.plist similarity index 100% rename from Tests/Result/Info.plist rename to Tests/ResultTests/Info.plist diff --git a/Tests/Result/ResultTests.swift b/Tests/ResultTests/ResultTests.swift similarity index 100% rename from Tests/Result/ResultTests.swift rename to Tests/ResultTests/ResultTests.swift From 2401fa7584183da17f40335816073bf511fb34b8 Mon Sep 17 00:00:00 2001 From: James Hurst Date: Wed, 3 Aug 2016 23:52:11 -0400 Subject: [PATCH 6/7] Revert "Renamed Tests/Result to Tests/ResultTests" This reverts commit db09c28f4004a7b0d68e9b4531a6e1b574f3e7da. --- Tests/{ResultTests => Result}/Info.plist | 0 Tests/{ResultTests => Result}/ResultTests.swift | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Tests/{ResultTests => Result}/Info.plist (100%) rename Tests/{ResultTests => Result}/ResultTests.swift (100%) diff --git a/Tests/ResultTests/Info.plist b/Tests/Result/Info.plist similarity index 100% rename from Tests/ResultTests/Info.plist rename to Tests/Result/Info.plist diff --git a/Tests/ResultTests/ResultTests.swift b/Tests/Result/ResultTests.swift similarity index 100% rename from Tests/ResultTests/ResultTests.swift rename to Tests/Result/ResultTests.swift From 908a26762eb899f4c25b019f85c5ec1bf3dabf38 Mon Sep 17 00:00:00 2001 From: James Hurst Date: Sat, 6 Aug 2016 18:10:41 -0400 Subject: [PATCH 7/7] Updated .swift-version to 3.0-PREVIEW-4 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index be77e20..d54e0b2 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-07-29-a +3.0-PREVIEW-4