Skip to content

Commit 3e7f323

Browse files
authored
Merge pull request #74464 from gregomni/issue-46902
[Sema] Fix hole where missing_nullary_call wasn't diagnosed in ternary condition.
2 parents c0c62cf + 10138d8 commit 3e7f323

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6545,6 +6545,9 @@ bool ConstraintSystem::repairFailures(
65456545
locator))
65466546
return true;
65476547

6548+
if (repairByInsertingExplicitCall(lhs, rhs))
6549+
return true;
6550+
65486551
conversionsOrFixes.push_back(IgnoreContextualType::create(
65496552
*this, lhs, rhs, getConstraintLocator(locator)));
65506553
break;

test/Constraints/ternary_expr.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ _ = true ? x : 1.2 // expected-error {{result values in '? :' expression have mi
5959
_ = (x: true) ? true : false // expected-error {{cannot convert value of type '(x: Bool)' to expected condition type 'Bool'}}
6060
_ = (x: 1) ? true : false // expected-error {{cannot convert value of type '(x: Int)' to expected condition type 'Bool'}}
6161

62+
func resultBool() -> Bool { true }
63+
_ = resultBool ? true : false // expected-error {{function 'resultBool' was used as a property; add () to call it}} {{15-15=()}}
64+
6265
let ib: Bool! = false
6366
let eb: Bool? = .some(false)
6467
let conditional = ib ? "Broken" : "Heart" // should infer Bool!

0 commit comments

Comments
 (0)