File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -577,8 +577,10 @@ ConstraintSystem::determineBestBindings() {
577
577
578
578
return bindings || !bindings.Defaults .empty () ||
579
579
llvm::any_of (bindings.Protocols , [&](Constraint *constraint) {
580
- return bool (
581
- TypeChecker::getDefaultType (constraint->getProtocol (), DC));
580
+ return constraint->getKind () ==
581
+ ConstraintKind::LiteralConformsTo &&
582
+ bool (TypeChecker::getDefaultType (constraint->getProtocol (),
583
+ DC));
582
584
});
583
585
};
584
586
Original file line number Diff line number Diff line change @@ -858,3 +858,15 @@ func rdar56212087() {
858
858
859
859
setValue ( foo ( " " , " " ) , forKey: " " ) // Ok (T is inferred as a `String` instead of `Any?`)
860
860
}
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
+ }
You can’t perform that action at this time.
0 commit comments