mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Split off Apple-specific parts of bidirectional_conversions.swift test
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
import Foundation
|
||||
import CoreGraphics
|
||||
|
||||
/////////////
|
||||
|
||||
@@ -20,26 +16,6 @@ func foo2(x: (Int, Int)?, y: (x: Int, y: Int)) -> G<(Int, Int)> {
|
||||
return g
|
||||
}
|
||||
|
||||
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 {}
|
||||
@@ -54,28 +30,6 @@ func bar2(x: (Int, Int)) {
|
||||
f(id(x))
|
||||
}
|
||||
|
||||
func bar3(x: @escaping () -> ()) {
|
||||
func f(_: @escaping @convention(block) () -> ()) {}
|
||||
// FIXME
|
||||
f(id(x)) // expected-error {{conflicting arguments to generic parameter 'T' ('@convention(block) () -> ()' vs. '() -> ()')}}
|
||||
}
|
||||
|
||||
func bar4(x: @escaping @convention(block) () -> ()) {
|
||||
func f(_: @escaping () -> ()) {}
|
||||
// FIXME
|
||||
f(id(x)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> ()' vs. '@convention(block) () -> ()')}}
|
||||
}
|
||||
|
||||
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 {}
|
||||
@@ -89,24 +43,3 @@ func baz2(x: (Int, Int)?) {
|
||||
func f(_: (x: Int, y: Int)) {}
|
||||
f(unwrap(x))
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
81
test/Constraints/bidirectional_conversions_objc.swift
Normal file
81
test/Constraints/bidirectional_conversions_objc.swift
Normal file
@@ -0,0 +1,81 @@
|
||||
// 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) () -> ()) {}
|
||||
// FIXME
|
||||
f(id(x)) // expected-error {{conflicting arguments to generic parameter 'T' ('@convention(block) () -> ()' vs. '() -> ()')}}
|
||||
}
|
||||
|
||||
func bar4(x: @escaping @convention(block) () -> ()) {
|
||||
func f(_: @escaping () -> ()) {}
|
||||
// FIXME
|
||||
f(id(x)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> ()' vs. '@convention(block) () -> ()')}}
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user