File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1075,7 +1075,7 @@ bool MissingExplicitConversionFailure::diagnoseAsError() {
1075
1075
} else {
1076
1076
// Emit error diagnostic.
1077
1077
emitDiagnostic (diag::cannot_coerce_to_type, fromType, toType);
1078
- // Emit and return note suggesting as! where the fixit will be placed.
1078
+ // Emit and return note suggesting as! where the fix-it will be placed.
1079
1079
return emitDiagnostic (diag::missing_forced_downcast);
1080
1080
}
1081
1081
};
Original file line number Diff line number Diff line change @@ -141,3 +141,16 @@ _ = sr6022 as! AnyObject // expected-warning {{forced cast from '() -> Any' to '
141
141
_ = sr6022 as? AnyObject // expected-warning {{conditional cast from '() -> Any' to 'AnyObject' always succeeds}}
142
142
_ = sr6022_1 as! Any // expected-warning {{forced cast from '() -> ()' to 'Any' always succeeds; did you mean to use 'as'?}}
143
143
_ = sr6022_1 as? Any // expected-warning {{conditional cast from '() -> ()' to 'Any' always succeeds}}
144
+
145
+ // SR-13899
146
+ let any : Any = 1
147
+ if let int = any as Int { // expected-error {{'Any' is not convertible to 'Int'}}
148
+ // expected-note@-1 {{did you mean to use 'as?' to conditionally downcast?}} {{18-20=as?}}
149
+ }
150
+
151
+ let _ = any as Int // expected-error {{'Any' is not convertible to 'Int'}}
152
+ // expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{13-15=as!}}
153
+ let _: Int = any as Int // expected-error {{'Any' is not convertible to 'Int'}}
154
+ // expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{18-20=as!}}
155
+ let _: Int ? = any as Int // expected-error {{'Any' is not convertible to 'Int'}}
156
+ // expected-note@-1 {{did you mean to use 'as?' to conditionally downcast?}} {{19-21=as?}}
You can’t perform that action at this time.
0 commit comments