Skip to content

Commit 1d6b041

Browse files
committed
Reword @objcImpl diagnostics to avoid “an”
…and also adopt new DiagnosticEngine features.
1 parent fca1402 commit 1d6b041

File tree

3 files changed

+38
-42
lines changed

3 files changed

+38
-42
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,9 +1694,9 @@ ERROR(attr_objc_implementation_no_conformance,none,
16941694
(Type, bool))
16951695

16961696
ERROR(member_of_objc_implementation_not_objc_or_final,none,
1697-
"%0 %1 does not match any %0 declared in the headers for %2; did you use "
1698-
"the %0's Swift name?",
1699-
(DescriptiveDeclKind, ValueDecl *, ValueDecl *))
1697+
"%kind0 does not match any %kindonly0 declared in the headers for %1; "
1698+
"did you use the %kindonly0's Swift name?",
1699+
(ValueDecl *, ValueDecl *))
17001700
NOTE(fixit_add_private_for_objc_implementation,none,
17011701
"add 'private' or 'fileprivate' to define an Objective-C-compatible %0 "
17021702
"not declared in the header",
@@ -1730,56 +1730,56 @@ ERROR(objc_implementation_required_attr_mismatch,none,
17301730
(ValueDecl *, DescriptiveDeclKind, bool))
17311731

17321732
ERROR(objc_implementation_candidate_has_error_convention,none,
1733-
"%0 %1 does not match the declaration in the header because it throws an "
1733+
"%kind0 does not match the declaration in the header because it throws an "
17341734
"error",
1735-
(DescriptiveDeclKind, ValueDecl *))
1735+
(const ValueDecl *))
17361736

17371737
ERROR(objc_implementation_candidate_lacks_error_convention,none,
1738-
"%0 %1 does not match the declaration in the header because it does not "
1738+
"%kind0 does not match the declaration in the header because it does not "
17391739
"throw an error",
1740-
(DescriptiveDeclKind, ValueDecl *))
1740+
(const ValueDecl *))
17411741

17421742
#define SELECT_FOREIGN_ERROR_CONVENTION_KIND \
17431743
"select{returning zero|returning non-zero|returning zero or a result|" \
17441744
"returning nil|setting the error parameter|%error}"
17451745

17461746
ERROR(objc_implementation_mismatched_error_convention_kind,none,
1747-
"%0 %1 does not match the declaration in the header because it indicates "
1748-
"an error by %" SELECT_FOREIGN_ERROR_CONVENTION_KIND "2, rather than by "
1749-
"%" SELECT_FOREIGN_ERROR_CONVENTION_KIND "3",
1750-
(DescriptiveDeclKind, ValueDecl *, unsigned, unsigned))
1747+
"%kind0 does not match the declaration in the header because it indicates "
1748+
"an error by %" SELECT_FOREIGN_ERROR_CONVENTION_KIND "1, rather than by "
1749+
"%" SELECT_FOREIGN_ERROR_CONVENTION_KIND "2",
1750+
(const ValueDecl *, unsigned, unsigned))
17511751

17521752
ERROR(objc_implementation_mismatched_error_convention_index,none,
1753-
"%0 %1 does not match the declaration in the header because it uses "
1754-
"parameter #%2 for the error, not parameter #%3; a selector part called "
1753+
"%kind0 does not match the declaration in the header because it uses "
1754+
"parameter #%1 for the error, not parameter #%2; a selector part called "
17551755
"'error:' can control which parameter to use",
1756-
(DescriptiveDeclKind, ValueDecl *, unsigned, unsigned))
1756+
(const ValueDecl *, unsigned, unsigned))
17571757

17581758
ERROR(objc_implementation_mismatched_error_convention_void_param,none,
1759-
"%0 %1 does not match the declaration in the header because it "
1760-
"%select{removes the error parameter|makes the error parameter 'Void'}2 "
1761-
"rather than %select{making it 'Void'|removing it}2",
1762-
(DescriptiveDeclKind, ValueDecl *, bool))
1759+
"%kind0 does not match the declaration in the header because it "
1760+
"%select{removes the error parameter|makes the error parameter 'Void'}1 "
1761+
"rather than %select{making it 'Void'|removing it}1",
1762+
(const ValueDecl *, bool))
17631763

17641764
ERROR(objc_implementation_mismatched_error_convention_ownership,none,
1765-
"%0 %1 does not match the declaration in the header because it "
1766-
"%select{does not own|owns}2 the error parameter",
1767-
(DescriptiveDeclKind, ValueDecl *, bool))
1765+
"%kind0 does not match the declaration in the header because it "
1766+
"%select{does not own|owns}1 the error parameter",
1767+
(const ValueDecl *, bool))
17681768

17691769
ERROR(objc_implementation_mismatched_error_convention_other,none,
1770-
"%0 %1 does not match the declaration in the header because it uses a "
1770+
"%kind0 does not match the declaration in the header because it uses a "
17711771
"different Objective-C error convention; please file a bug report with a "
17721772
"sample project, as the compiler should be able to describe the mismatch",
1773-
(DescriptiveDeclKind, ValueDecl *))
1773+
(const ValueDecl *))
17741774

17751775
ERROR(objc_implementation_wrong_objc_name,none,
17761776
"selector %0 for %kind1 not found in header; did you mean %2?",
17771777
(ObjCSelector, ValueDecl *, ObjCSelector))
17781778

17791779
ERROR(objc_implementation_wrong_swift_name,none,
1780-
"selector %0 used in header by an %1 with a different name; did you "
1781-
"mean %2?",
1782-
(ObjCSelector, DescriptiveDeclKind, DeclName))
1780+
"selector %0 used in header by %kindonly1 with a different name; did "
1781+
"you mean %1?",
1782+
(ObjCSelector, const ValueDecl *))
17831783

17841784
ERROR(objc_implementation_missing_impl,none,
17851785
"extension for %select{main class interface|category %0}0 should "

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,8 +3379,7 @@ class ObjCImplementationChecker {
33793379

33803380
case MatchOutcome::WrongSwiftName: {
33813381
auto diag = diagnose(cand, diag::objc_implementation_wrong_swift_name,
3382-
reqObjCName, req->getDescriptiveKind(),
3383-
req->getName());
3382+
reqObjCName, req);
33843383
fixDeclarationName(diag, cand, req->getName());
33853384
if (!explicitObjCName) {
33863385
// Changing the Swift name will probably change the implicitly-computed
@@ -3444,38 +3443,36 @@ class ObjCImplementationChecker {
34443443
if (reqConv && !candConv)
34453444
diagnose(cand,
34463445
diag::objc_implementation_candidate_has_error_convention,
3447-
cand->getDescriptiveKind(), cand);
3446+
cand);
34483447
else if (!reqConv && candConv)
34493448
diagnose(cand,
34503449
diag::objc_implementation_candidate_lacks_error_convention,
3451-
cand->getDescriptiveKind(), cand);
3450+
cand);
34523451
else if (reqConv->getKind() != candConv->getKind())
34533452
diagnose(cand,
34543453
diag::objc_implementation_mismatched_error_convention_kind,
3455-
cand->getDescriptiveKind(), cand, candConv->getKind(),
3456-
reqConv->getKind());
3454+
cand, candConv->getKind(), reqConv->getKind());
34573455
else if (reqConv->getErrorParameterIndex()
34583456
!= candConv->getErrorParameterIndex())
34593457
diagnose(cand,
34603458
diag::objc_implementation_mismatched_error_convention_index,
3461-
cand->getDescriptiveKind(), cand,
3459+
cand,
34623460
candConv->getErrorParameterIndex() + 1,
34633461
reqConv->getErrorParameterIndex() + 1);
34643462
else if (reqConv->isErrorParameterReplacedWithVoid()
34653463
!= candConv->isErrorParameterReplacedWithVoid())
34663464
diagnose(cand,
34673465
diag::objc_implementation_mismatched_error_convention_void_param,
3468-
cand->getDescriptiveKind(), cand,
3469-
candConv->isErrorParameterReplacedWithVoid());
3466+
cand, candConv->isErrorParameterReplacedWithVoid());
34703467
else if (reqConv->isErrorOwned() != candConv->isErrorOwned())
34713468
diagnose(cand,
34723469
diag::objc_implementation_mismatched_error_convention_ownership,
3473-
cand->getDescriptiveKind(), cand, candConv->isErrorOwned());
3470+
cand, candConv->isErrorOwned());
34743471
else
34753472
// Catch-all; probably shouldn't happen.
34763473
diagnose(cand,
34773474
diag::objc_implementation_mismatched_error_convention_other,
3478-
cand->getDescriptiveKind(), cand);
3475+
cand);
34793476

34803477
return;
34813478
}
@@ -3524,8 +3521,7 @@ class ObjCImplementationChecker {
35243521
auto cand = pair.first;
35253522

35263523
diagnose(cand, diag::member_of_objc_implementation_not_objc_or_final,
3527-
cand->getDescriptiveKind(), cand,
3528-
cand->getDeclContext()->getSelfClassDecl());
3524+
cand, cand->getDeclContext()->getSelfClassDecl());
35293525

35303526
if (canBeRepresentedInObjC(cand))
35313527
diagnose(cand, diag::fixit_add_private_for_objc_implementation,

test/decl/ext/objc_implementation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ protocol EmptySwiftProto {}
258258
}
259259

260260
func methodObjCName3() {
261-
// expected-error@-1 {{selector 'methodObjCName3' used in header by an instance method with a different name; did you mean 'methodSwiftName3()'?}} {{8-23=methodSwiftName3}} {{3-3=@objc(methodObjCName3) }}
261+
// expected-error@-1 {{selector 'methodObjCName3' used in header by instance method with a different name; did you mean 'methodSwiftName3()'?}} {{8-23=methodSwiftName3}} {{3-3=@objc(methodObjCName3) }}
262262
// FIXME: probably needs an @objc too, since the name is not explicit
263263
}
264264

@@ -267,11 +267,11 @@ protocol EmptySwiftProto {}
267267
}
268268

269269
@objc(methodObjCName5) func methodWrongSwiftName5() {
270-
// expected-error@-1 {{selector 'methodObjCName5' used in header by an instance method with a different name; did you mean 'methodSwiftName5()'?}} {{31-52=methodSwiftName5}}
270+
// expected-error@-1 {{selector 'methodObjCName5' used in header by instance method with a different name; did you mean 'methodSwiftName5()'?}} {{31-52=methodSwiftName5}}
271271
}
272272

273273
@objc(methodObjCName6A) func methodSwiftName6B() {
274-
// expected-error@-1 {{selector 'methodObjCName6A' used in header by an instance method with a different name; did you mean 'methodSwiftName6A()'?}} {{32-49=methodSwiftName6A}}
274+
// expected-error@-1 {{selector 'methodObjCName6A' used in header by instance method with a different name; did you mean 'methodSwiftName6A()'?}} {{32-49=methodSwiftName6A}}
275275
}
276276
}
277277

0 commit comments

Comments
 (0)