mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[TypeChecker] NFC: Add a test-case to test condition requirements interaction with transitive conformance checks
This commit is contained in:
@@ -454,3 +454,23 @@ func test_inference_through_implicit_conversion() {
|
||||
let _: UnsafePointer<C> = test([C()]) // Ok - argument is implicitly converted to a pointer
|
||||
let _: AnyHashable = test(C()) // Ok - argument is implicitly converted to `AnyHashable` because it's Hashable
|
||||
}
|
||||
|
||||
// Make sure that conformances transitively checked through implicit conversions work with conditional requirements
|
||||
protocol TestCond {}
|
||||
|
||||
extension Optional : TestCond where Wrapped == Int? {}
|
||||
|
||||
func simple<T : TestCond>(_ x: T) -> T { x }
|
||||
|
||||
func overloaded<T: TestCond>(_ x: T) -> T { x }
|
||||
func overloaded<T: TestCond>(_ x: String) -> T { fatalError() }
|
||||
|
||||
func overloaded_result() -> Int { 42 }
|
||||
func overloaded_result() -> String { "" }
|
||||
|
||||
func test_arg_conformance_with_conditional_reqs(i: Int) {
|
||||
let _: Int?? = simple(i)
|
||||
let _: Int?? = overloaded(i)
|
||||
let _: Int?? = simple(overloaded_result())
|
||||
let _: Int?? = overloaded(overloaded_result())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user