Skip to content

Commit d448a77

Browse files
authored
Merge pull request swiftlang#37098 from xedin/rdar-77233864-testcase
[TypeChecker] NFC: Add a test-case for rdar://77233864
2 parents f6d49ba + 40a32dc commit d448a77

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
@@ -858,3 +858,15 @@ func rdar56212087() {
858858

859859
setValue(foo("", ""), forKey: "") // Ok (T is inferred as a `String` instead of `Any?`)
860860
}
861+
862+
// rdar://77233864 - Ternary operator fails to deduce non-default literal type in SwiftUI preview
863+
func test_ternary_operator_with_regular_conformance_to_literal_protocol() {
864+
// Note that in this case `ExpressibleByIntegerLiteral` is a non-literal requirement
865+
func test<T: ExpressibleByIntegerLiteral>(_: T) -> T {
866+
fatalError()
867+
}
868+
869+
func bug(_: Float?) {}
870+
871+
bug(true ? test(0) : test(42)) // Ok - type is `CGFloat` for 0 and 42
872+
}

0 commit comments

Comments
 (0)