mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove function-to-function type match score increase, which should only happen contextually in presence of other restrictions, this used to fix the case related to matching of arrays of functions with and w/e `throws` as function parameters which used to be ambigious, and now handled by collection-upcast conversion score. Resolves: rdar://problem/35142121
45 lines
845 B
Swift
45 lines
845 B
Swift
// RUN: %target-typecheck-verify-swift -swift-version 3
|
|
// RUN: %target-typecheck-verify-swift -swift-version 4
|
|
|
|
// rdar://problem/31969605
|
|
|
|
class Base {}
|
|
class Derived : Base {}
|
|
|
|
protocol Refined {}
|
|
protocol Proto : Refined {}
|
|
extension Base : Refined {}
|
|
|
|
func baseFn(_: Base) {}
|
|
|
|
func superclassConversion(fn: @escaping (Base) -> ()) {
|
|
let _: (Derived) -> () = fn
|
|
}
|
|
|
|
func existentialConversion(fn: @escaping (Refined) -> ()) {
|
|
let _: (Proto) -> () = fn
|
|
let _: (Base) -> () = fn
|
|
let _: (Derived) -> () = fn
|
|
}
|
|
|
|
// rdar://problem/31725325
|
|
|
|
func a<b>(_: [(String, (b) -> () -> Void)]) {}
|
|
func a<b>(_: [(String, (b) -> () throws -> Void)]) {}
|
|
|
|
class c {
|
|
func e() {}
|
|
static var d = [("", e)]
|
|
}
|
|
a(c.d)
|
|
|
|
func b<T>(_: (T) -> () -> ()) {}
|
|
|
|
b(c.e)
|
|
|
|
func bar(_: () -> ()) {}
|
|
func bar(_: () throws -> ()) {}
|
|
func bar_empty() {}
|
|
|
|
bar(bar_empty)
|