mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This fixes an ambiguity introduced by the stdlib change in
0f99458900.
Since (borrowing T) -> () and (T) -> () both convert to
each other, we could end up with ambiguous solutions where
neither one was better than the other. Generalize the
existing trick we use for labeled vs unlabeled tuples to
also strip off ownership specifiers and @convention(...)
from function types. This fixes the regression, as well
an existing FIXME in a test I added a while ago where
the same problem arises with @convention(block).
79 lines
1.3 KiB
Swift
79 lines
1.3 KiB
Swift
// RUN: %target-typecheck-verify-swift
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import CoreGraphics
|
|
|
|
/////////////
|
|
|
|
struct G<T> {
|
|
var t: T
|
|
}
|
|
|
|
func foo3(x: (@convention(block) () -> ())?, y: @escaping () -> ()) -> G<@convention(block) () -> ()> {
|
|
let g = G(t: x ?? y)
|
|
return g
|
|
}
|
|
|
|
func foo4(x: (() -> ())?, y: @escaping @convention(block) () -> ()) -> G<() -> ()> {
|
|
let g = G(t: x ?? y)
|
|
return g
|
|
}
|
|
|
|
func foo5(x: CGFloat?, y: Double) -> G<CGFloat> {
|
|
let g = G(t: x ?? y)
|
|
return g
|
|
}
|
|
|
|
func foo6(x: Double?, y: CGFloat) -> G<Double> {
|
|
let g = G(t: x ?? y)
|
|
return g
|
|
}
|
|
|
|
/////////////
|
|
|
|
func id<T>(_: T) -> T {}
|
|
|
|
func bar3(x: @escaping () -> ()) {
|
|
func f(_: @escaping @convention(block) () -> ()) {}
|
|
f(id(x))
|
|
}
|
|
|
|
func bar4(x: @escaping @convention(block) () -> ()) {
|
|
func f(_: @escaping () -> ()) {}
|
|
f(id(x))
|
|
}
|
|
|
|
func bar5(x: Double) {
|
|
func f(_: CGFloat) {}
|
|
f(id(x))
|
|
}
|
|
|
|
func bar6(x: CGFloat) {
|
|
func f(_: Double) {}
|
|
f(id(x))
|
|
}
|
|
|
|
/////////////
|
|
|
|
func unwrap<T>(_: T?) -> T {}
|
|
|
|
func baz3(x: (() -> ())?) {
|
|
func f(_: @escaping @convention(block) () -> ()) {}
|
|
f(unwrap(x))
|
|
}
|
|
|
|
func baz4(x: (@convention(block) () -> ())?) {
|
|
func f(_: @escaping () -> ()) {}
|
|
f(unwrap(x))
|
|
}
|
|
|
|
func baz5(x: Double?) {
|
|
func f(_: CGFloat) {}
|
|
f(unwrap(x))
|
|
}
|
|
|
|
func baz6(x: CGFloat?) {
|
|
func f(_: Double) {}
|
|
f(unwrap(x))
|
|
} |