File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-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
+ }
Original file line number Diff line number Diff line change 121
121
} // expected-error {{expected expression after operator}}
122
122
123
123
_ = /x/ ??/ x/ // expected-error {{'/' is not a postfix unary operator}}
124
+ // expected-error@-1 2 {{cannot use optional chaining on non-optional value of type 'Regex<Substring>'}}
124
125
125
126
_ = /x/ ... /y/ // expected-error {{referencing operator function '...' on 'Comparable' requires that 'Regex<Substring>' conform to 'Comparable'}}
126
127
You can’t perform that action at this time.
0 commit comments