Skip to content

Commit

Permalink
Fix compatibility with Swift 5 compiler
Browse files Browse the repository at this point in the history
This works around [SR-9753][https://bugs.swift.org/browse/SR-9753].

Fixes #31.
  • Loading branch information
lilyball committed Jan 29, 2019
1 parent 4c9b78e commit 9bf3eba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ Unless you explicitly state otherwise, any contribution intentionally submitted

## Version History

### Development

- Fix compatibility with Xcode 10.2 / Swift 5 compiler ([#31][], [SR-9753][]).

[#31]: https://github.com/lilyball/Tomorrowland/issues/31 "\"Ambiguous use of Promise.pipe(to:)\" error building with Xcode 10.2 Beta 1 in Swift 4 mode"
[SR-9753]: https://bugs.swift.org/browse/SR-9753 "REGRESSION: Ambiguity involving overloads and generics constrained by Error"

### v0.4.2

- Add new method `Promise.Resolver.resolve(with: somePromise)` that resolves the receiver using another promise ([#30][]).
Expand Down
10 changes: 5 additions & 5 deletions Sources/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public struct Promise<Value,Error> {
}
do {
let nextPromise = try onComplete(result)
nextPromise.pipe(to: resolver)
nextPromise.pipe(toStd: resolver)
} catch {
resolver.reject(with: error)
}
Expand Down Expand Up @@ -830,11 +830,11 @@ extension Promise where Error: Swift.Error {
/// an error, it's upcast to `Swift.Error`.
public var upcast: Promise<Value,Swift.Error> {
let (promise, resolver) = Promise<Value,Swift.Error>.makeWithResolver()
pipe(to: resolver)
pipe(toStd: resolver)
return promise
}

private func pipe(to resolver: Promise<Value,Swift.Error>.Resolver) {
private func pipe(toStd resolver: Promise<Value,Swift.Error>.Resolver) {
_seal.enqueue { (result) in
resolver.resolve(with: result)
}
Expand Down Expand Up @@ -990,7 +990,7 @@ extension Promise where Error == Swift.Error {
}
do {
let nextPromise = try onSuccess(value)
nextPromise.pipe(to: resolver)
nextPromise.pipe(toStd: resolver)
} catch {
resolver.reject(with: error)
}
Expand Down Expand Up @@ -1111,7 +1111,7 @@ extension Promise where Error == Swift.Error {
}
do {
let nextPromise = try onError(error)
nextPromise.pipe(to: resolver)
nextPromise.pipe(toStd: resolver)
} catch {
resolver.reject(with: error)
}
Expand Down

0 comments on commit 9bf3eba

Please sign in to comment.