File tree Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -2235,6 +2235,10 @@ class RemoveInvalidCall final : public ConstraintFix {
2235
2235
2236
2236
bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2237
2237
2238
+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
2239
+ return diagnose (*commonFixes.front ().first );
2240
+ }
2241
+
2238
2242
static RemoveInvalidCall *create (ConstraintSystem &cs,
2239
2243
ConstraintLocator *locator);
2240
2244
@@ -2468,6 +2472,10 @@ class SpecifyKeyPathRootType final : public ConstraintFix {
2468
2472
2469
2473
bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2470
2474
2475
+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
2476
+ return diagnose (*commonFixes.front ().first );
2477
+ }
2478
+
2471
2479
static SpecifyKeyPathRootType *create (ConstraintSystem &cs,
2472
2480
ConstraintLocator *locator);
2473
2481
Original file line number Diff line number Diff line change @@ -1484,3 +1484,8 @@ func testUnwrapFixIts(x: Int?) throws {
1484
1484
// expected-note@-2 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{42-42=!}}
1485
1485
let _: Int = try ! . optionalThrowsMember ?? 0
1486
1486
}
1487
+
1488
+ func rdar86611718( list: [ Int ] ) {
1489
+ String ( list. count ( ) )
1490
+ // expected-error@-1 {{cannot call value of non-function type 'Int'}}
1491
+ }
Original file line number Diff line number Diff line change @@ -188,3 +188,21 @@ func testSR13442() {
188
188
_ = SR13442 ( \String ? .!. count) // OK
189
189
let _: KeyPath < Int ? , Int > = \Optional .!
190
190
}
191
+
192
+ // rdar://85458997 - failed to produce a diagnostic about key path root type
193
+ func rdar85458997( ) {
194
+ struct S < R> {
195
+ init ( _: KeyPath < R , String > ) {
196
+ }
197
+
198
+ init ( _: KeyPath < R , Int > ) {
199
+ }
200
+ }
201
+
202
+ struct V {
203
+ var name : String
204
+ }
205
+
206
+ _ = S ( \. name)
207
+ // expected-error@-1 {{cannot infer key path type from context; consider explicitly specifying a root type}} {{10-10=<#Root#>}}
208
+ }
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ takesP1AndP2([Swift.DoesNotExist & P1 & P2]()) // expected-error {{module 'Swift
177
177
// expected-error@-1 {{binary operator '&' cannot be applied to operands of type 'UInt8' and 'P1.Protocol'}}
178
178
// expected-error@-2 {{binary operator '&' cannot be applied to operands of type 'UInt8' and 'P2.Protocol'}}
179
179
// 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]'}}
181
181
182
182
typealias T08 = P1 & inout P2 // expected-error {{'inout' may only be used on parameters}}
183
183
typealias T09 = P1 & __shared P2 // expected-error {{'__shared' may only be used on parameters}}
You can’t perform that action at this time.
0 commit comments