[TypeChecker] NFC: Add a test-case to test condition requirements interaction with transitive conformance checks

This commit is contained in:
Pavel Yaskevich
2021-04-08 16:02:32 -07:00
parent 6add8f282f
commit 2137e1bafd

View File

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