Skip to content

Commit 74600db

Browse files
committed
[TypeChecker] NFC: Add a test-case for fixed rdar://problem/56212087
1 parent 7ce37dd commit 74600db

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Constraints/generics.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,15 @@ func test_dictionary_with_generic_mismatch_in_key_or_value() {
846846
let _: [S<Bool>: Int] = [S<Int>(): 42]
847847
// expected-error@-1 {{cannot convert value of type 'S<Int>' to expected dictionary key type 'S<Bool>'}}
848848
}
849+
850+
851+
// rdar://problem/56212087 - unable to infer type for generic parameter `T`
852+
func rdar56212087() {
853+
func setValue(_: Any?, forKey: String) {}
854+
855+
func foo<T: ExpressibleByStringLiteral>(_: String, _: T) -> T {
856+
fatalError()
857+
}
858+
859+
setValue(foo("", ""), forKey: "") // Ok (T is inferred as a `String` instead of `Any?`)
860+
}

0 commit comments

Comments
 (0)