Skip to content

Commit ce135e6

Browse files
authored
Merge pull request #36691 from xedin/a-couple-of-tests
[TypeChecker] NFC: Add a couple of tests for inference with optional/…
2 parents 26a4d5c + ae8efa3 commit ce135e6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/Constraints/protocols.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,20 @@ func rdar70814576() {
432432

433433
test(S()) // expected-error {{argument type 'S' does not conform to expected type 'Fooable'}}
434434
}
435+
436+
extension Optional : Trivial {
437+
typealias T = Wrapped
438+
}
439+
440+
extension UnsafePointer : Trivial {
441+
typealias T = Int
442+
}
443+
444+
func test_inference_through_implicit_conversion() {
445+
class C {}
446+
447+
func test<T: Trivial>(_: T) -> T {}
448+
449+
let _: C? = test(C()) // Ok -> argument is implicitly promoted into an optional
450+
let _: UnsafePointer<C> = test([C()]) // Ok - argument is implicitly converted to a pointer
451+
}

0 commit comments

Comments
 (0)