Skip to content

Commit 10138d8

Browse files
author
Greg Titus
committed
Fix hole where missing_nullary_call wasn't diagnosed in ternary condition.
1 parent 25830d6 commit 10138d8

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
@@ -6524,6 +6524,9 @@ bool ConstraintSystem::repairFailures(
65246524
locator))
65256525
return true;
65266526

6527+
if (repairByInsertingExplicitCall(lhs, rhs))
6528+
return true;
6529+
65276530
conversionsOrFixes.push_back(IgnoreContextualType::create(
65286531
*this, lhs, rhs, getConstraintLocator(locator)));
65296532
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)