mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If we could find a binding for type variable representing closure result let's also add implicit `Void` type as another pontential binding to attempt because there is an implicit conversion from `() -> T` to `() -> Void` so finding `Void` early is going to help avoid function conversions down the line. Resolves: rdar://problem/37790062
47 lines
916 B
Swift
47 lines
916 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol A {
|
|
associatedtype V
|
|
associatedtype E: Error
|
|
|
|
init(value: V)
|
|
init(error: E)
|
|
|
|
func foo<U>(value: (V) -> U, error: (E) -> U) -> U
|
|
}
|
|
|
|
enum R<T, E: Error> : A {
|
|
case foo(T)
|
|
case bar(E)
|
|
|
|
init(value: T) { self = .foo(value) }
|
|
init(error: E) { self = .bar(error) }
|
|
|
|
func foo<R>(value: (T) -> R, error: (E) -> R) -> R {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
protocol P {
|
|
associatedtype V
|
|
|
|
@discardableResult
|
|
func baz(callback: @escaping (V) -> Void) -> Self
|
|
}
|
|
|
|
class C<V> : P {
|
|
func baz(callback: @escaping (V) -> Void) -> Self { return self }
|
|
}
|
|
class D<T, E: Error> : C<R<T, E>> {
|
|
init(fn: (_ ret: @escaping (V) -> Void) -> Void) {}
|
|
}
|
|
|
|
extension A where V: P, V.V: A, E == V.V.E {
|
|
func bar() -> D<V.V.V, V.V.E> {
|
|
return D { complete in
|
|
foo(value: { promise in promise.baz { result in } },
|
|
error: { complete(R(error: $0)) })
|
|
}
|
|
}
|
|
}
|