Sema: Split off Apple-specific parts of bidirectional_conversions.swift test

This commit is contained in:
Slava Pestov
2025-12-09 17:31:19 -05:00
parent 3e2943ff62
commit 1e9f8826a7
2 changed files with 81 additions and 67 deletions

View File

@@ -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))
}

View 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))
}