diff --git a/.travis.yml b/.travis.yml index 9a708b7..17ee849 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,5 +29,16 @@ matrix: language: generic install: - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)" + - script: + - swift build + - swift test + env: + - JOB=Linux + - SWIFT_VERSION=3.1-DEVELOPMENT-SNAPSHOT-2017-03-01-a + sudo: required + dist: trusty + language: generic + install: + - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)" notifications: email: false diff --git a/Result/Result.swift b/Result/Result.swift index 5dd14cd..b08ea8e 100644 --- a/Result/Result.swift +++ b/Result/Result.swift @@ -129,8 +129,17 @@ public func materialize(_ f: () throws -> T) -> Result { public func materialize(_ f: @autoclosure () throws -> T) -> Result { do { return .success(try f()) - } catch let error as NSError { - return .failure(error) + } catch { +// This isn't great, but it lets us maintain compatibility until this deprecated +// method can be removed. +#if _runtime(_ObjC) + return .failure(error as NSError) +#else + // https://github.com/apple/swift-corelibs-foundation/blob/swift-3.0.2-RELEASE/Foundation/NSError.swift#L314 + let userInfo = _swift_Foundation_getErrorDefaultUserInfo(error) as? [String: Any] + let nsError = NSError(domain: error._domain, code: error._code, userInfo: userInfo) + return .failure(nsError) +#endif } }