Skip to content

Commit cdc472f

Browse files
committed
[CSFix] Make it possible to diagnose calls to non-functions in ambiguity contexts
Resolves: rdar://86611718 (cherry picked from commit d5b11a6)
1 parent 7b9d0ef commit cdc472f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

include/swift/Sema/CSFix.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,10 @@ class RemoveInvalidCall final : public ConstraintFix {
22352235

22362236
bool diagnose(const Solution &solution, bool asNote = false) const override;
22372237

2238+
bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override {
2239+
return diagnose(*commonFixes.front().first);
2240+
}
2241+
22382242
static RemoveInvalidCall *create(ConstraintSystem &cs,
22392243
ConstraintLocator *locator);
22402244

test/Constraints/diagnostics.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,3 +1484,8 @@ func testUnwrapFixIts(x: Int?) throws {
14841484
// expected-note@-2 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{42-42=!}}
14851485
let _: Int = try! .optionalThrowsMember ?? 0
14861486
}
1487+
1488+
func rdar86611718(list: [Int]) {
1489+
String(list.count())
1490+
// expected-error@-1 {{cannot call value of non-function type 'Int'}}
1491+
}

test/type/protocol_composition.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ takesP1AndP2([Swift.DoesNotExist & P1 & P2]()) // expected-error {{module 'Swift
177177
// expected-error@-1 {{binary operator '&' cannot be applied to operands of type 'UInt8' and 'P1.Protocol'}}
178178
// expected-error@-2 {{binary operator '&' cannot be applied to operands of type 'UInt8' and 'P2.Protocol'}}
179179
// expected-note@-3 2 {{overloads for '&' exist with these partially matching parameter lists}}
180-
180+
// expected-error@-4 {{cannot call value of non-function type '[UInt8]'}}
181181

182182
typealias T08 = P1 & inout P2 // expected-error {{'inout' may only be used on parameters}}
183183
typealias T09 = P1 & __shared P2 // expected-error {{'__shared' may only be used on parameters}}

0 commit comments

Comments
 (0)