Skip to content

Commit d669d15

Browse files
committed
Add fix-its when an override has mismatched optionals.
1 parent 996ee1e commit d669d15

File tree

4 files changed

+428
-161
lines changed

4 files changed

+428
-161
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,8 +1329,8 @@ ERROR(override_multiple_decls_arg_mismatch,none,
13291329
"declaration %0 has different argument names from any potential "
13301330
"overrides", (DeclName))
13311331
NOTE(overridden_near_match_here,none,
1332-
"potential overridden %select{method|initializer}0 %1 here",
1333-
(bool, DeclName))
1332+
"potential overridden %0 %1 here",
1333+
(DescriptiveDeclKind, DeclName))
13341334
ERROR(override_decl_extension,none,
13351335
"declarations %select{in extensions|from extensions}0 cannot "
13361336
"%select{override|be overridden}0 yet", (bool))
@@ -1416,6 +1416,12 @@ ERROR(override_throws_objc,none,
14161416
"overriding a throwing @objc %select{method|initializer}0 with "
14171417
"a non-throwing %select{method|initializer}0 is not supported", (bool))
14181418

1419+
ERROR(override_optional_mismatch,none,
1420+
"cannot override %0 parameter of type %1 with non-optional type %2",
1421+
(DescriptiveDeclKind, Type, Type))
1422+
ERROR(override_optional_result_mismatch,none,
1423+
"cannot override %0 result type %1 with optional type %2",
1424+
(DescriptiveDeclKind, Type, Type))
14191425
WARNING(override_unnecessary_IUO,none,
14201426
"overriding %0 parameter of type %1 with implicitly unwrapped optional "
14211427
"type %2",

0 commit comments

Comments
 (0)