File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2468,6 +2468,10 @@ class SpecifyKeyPathRootType final : public ConstraintFix {
2468
2468
2469
2469
bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2470
2470
2471
+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
2472
+ return diagnose (*commonFixes.front ().first );
2473
+ }
2474
+
2471
2475
static SpecifyKeyPathRootType *create (ConstraintSystem &cs,
2472
2476
ConstraintLocator *locator);
2473
2477
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
+ }
You can’t perform that action at this time.
0 commit comments