Skip to content

Commit 02fdf65

Browse files
committed
Don’t be ambiguous for promise.done { _ in etc.
1 parent 88af2d7 commit 02fdf65

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Sources/PromiseKit/Wrappers/ThenableWrappers.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public extension _PMKSharedWrappers {
1919
- Parameter body: The closure that is executed when this Promise is fulfilled.
2020
- Returns: A new promise fulfilled as `Void`.
2121
*/
22+
@_disfavoredOverload
2223
func done(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) throws -> Void) -> BaseOfVoid {
2324
let dispatcher = selectDispatcher(given: on, configured: conf.D.return, flags: flags)
2425
return done(on: dispatcher, body)
@@ -45,6 +46,7 @@ public extension _PMKSharedWrappers {
4546
- Parameter body: The closure that is executed when this Promise is fulfilled.
4647
- Returns: A new promise that is resolved with the value that the handler is fed.
4748
*/
49+
@_disfavoredOverload
4850
func get(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping (T) throws -> Void) -> BaseOfT {
4951
let dispatcher = selectDispatcher(given: on, configured: conf.D.return, flags: flags)
5052
return get(on: dispatcher, body)
@@ -62,6 +64,7 @@ public extension _PMKSharedWrappers {
6264
- Parameter body: The closure that is executed with Result of Promise.
6365
- Returns: A new promise that is resolved with the result that the handler is fed.
6466
*/
67+
@_disfavoredOverload
6568
func tap(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(Result<T, Error>) -> Void) -> BaseOfT {
6669
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
6770
return tap(on: dispatcher, body)
@@ -88,6 +91,7 @@ public extension Thenable {
8891
- Parameter body: The closure that executes when this promise fulfills. It must return a promise.
8992
- Returns: A new promise that resolves when the promise returned from the provided closure resolves.
9093
*/
94+
@_disfavoredOverload
9195
func then<U: Thenable>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) throws -> U) -> Promise<U.T> {
9296
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
9397
return then(on: dispatcher, body)
@@ -111,6 +115,7 @@ public extension Thenable {
111115
//…
112116
}
113117
*/
118+
@_disfavoredOverload
114119
func map<U>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ transform: @escaping(T) throws -> U) -> Promise<U> {
115120
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
116121
return map(on: dispatcher, transform)
@@ -131,6 +136,7 @@ public extension Thenable {
131136
// either `PMKError.compactMap` or a `JSONError`
132137
}
133138
*/
139+
@_disfavoredOverload
134140
func compactMap<U>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ transform: @escaping(T) throws -> U?) -> Promise<U> {
135141
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
136142
return compactMap(on: dispatcher, transform)
@@ -159,6 +165,7 @@ public extension CancellableThenable {
159165
- Parameter body: The closure that executes when this cancellable promise fulfills. It must return a cancellable promise.
160166
- Returns: A new cancellable promise that resolves when the promise returned from the provided closure resolves.
161167
*/
168+
@_disfavoredOverload
162169
func then<V: CancellableThenable>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping (U.T) throws -> V) -> CancellablePromise<V.U.T> {
163170
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
164171
return then(on: dispatcher, body)
@@ -184,6 +191,7 @@ public extension CancellableThenable {
184191
- Parameter body: The closure that executes when this cancellable promise fulfills. It must return a promise (not a cancellable promise).
185192
- Returns: A new cancellable promise that resolves when the promise returned from the provided closure resolves.
186193
*/
194+
@_disfavoredOverload
187195
func then<V: Thenable>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping (U.T) throws -> V) -> CancellablePromise<V.T> {
188196
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
189197
return then(on: dispatcher, body)
@@ -209,6 +217,7 @@ public extension CancellableThenable {
209217
- Parameter transform: The closure that is executed when this CancellablePromise is fulfilled. It must return a non-promise and non-cancellable-promise.
210218
- Returns: A new cancellable promise that is resolved with the value returned from the provided closure.
211219
*/
220+
@_disfavoredOverload
212221
func map<V>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ transform: @escaping (U.T) throws -> V) -> CancellablePromise<V> {
213222
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
214223
return map(on: dispatcher, transform)
@@ -232,6 +241,7 @@ public extension CancellableThenable {
232241
//…
233242
context.cancel()
234243
*/
244+
@_disfavoredOverload
235245
func compactMap<V>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ transform: @escaping (U.T) throws -> V?) -> CancellablePromise<V> {
236246
let dispatcher = selectDispatcher(given: on, configured: conf.D.map, flags: flags)
237247
return compactMap(on: dispatcher, transform)

0 commit comments

Comments
 (0)