File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1205,6 +1205,10 @@ class RemoveUnwrap final : public ConstraintFix {
1205
1205
1206
1206
bool diagnose (const Solution &solution, bool asNote = false ) const override ;
1207
1207
1208
+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
1209
+ return diagnose (*commonFixes.front ().first );
1210
+ }
1211
+
1208
1212
static RemoveUnwrap *create (ConstraintSystem &cs, Type baseType,
1209
1213
ConstraintLocator *locator);
1210
1214
Original file line number Diff line number Diff line change @@ -588,4 +588,14 @@ do {
588
588
takesP ( value)
589
589
// expected-error@-1 {{argument type '(any BinaryInteger)?' does not conform to expected type 'P'}}
590
590
}
591
- }
591
+ }
592
+
593
+ // Diagnose extraneous force unwrap in ambiguous context
594
+ do {
595
+ func test( _: Int ) { } // expected-note {{found this candidate}}
596
+ func test( _: String ) { } // expected-note {{found this candidate}}
597
+
598
+ var x : Double = 42
599
+ test ( x!) // expected-error {{no exact matches in call to local function 'test'}}
600
+ // expected-error@-1 {{cannot force unwrap value of non-optional type 'Double'}}
601
+ }
You can’t perform that action at this time.
0 commit comments