Skip to content

Commit c642a7f

Browse files
update diagnostics
1 parent cbdb274 commit c642a7f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,11 +1801,11 @@ ERROR(type_cannot_conform_to_nsobject,none,
18011801

18021802
ERROR(use_of_equal_instead_of_equality,none,
18031803
"use of '=' in a boolean context, did you mean '=='?", ())
1804-
18051804
ERROR(type_cannot_conform, none,
1806-
"%select{|A value of protocol }0type %1 does not conform to the protocol itself (exception: 'Error'); "
1805+
"%select{type %1|protocol %1 as a type}0 cannot conform to "
1806+
"%select{%3|the protocol itself}2; "
18071807
"only concrete types such as structs, enums and classes can conform to protocols",
1808-
(bool, Type, Type))
1808+
(bool, Type, bool, Type))
18091809
NOTE(required_by_opaque_return,none,
18101810
"required by opaque return type of %0 %1", (DescriptiveDeclKind, DeclName))
18111811
NOTE(required_by_decl,none,

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ bool MissingConformanceFailure::diagnoseTypeCannotConform(
474474
}
475475

476476
emitDiagnostic(diag::type_cannot_conform,
477-
nonConformingType->isExistentialType(), nonConformingType,
477+
nonConformingType->isExistentialType(), nonConformingType, nonConformingType->isEqual(protocolType),
478478
protocolType);
479479

480480
if (auto *OTD = dyn_cast<OpaqueTypeDecl>(AffectedDecl)) {
@@ -2061,7 +2061,7 @@ bool ContextualFailure::diagnoseAsError() {
20612061
if (CTP == CTP_ForEachStmt) {
20622062
if (fromType->isAnyExistentialType()) {
20632063
emitDiagnostic(diag::type_cannot_conform,
2064-
/*isExistentialType=*/true, fromType, toType);
2064+
/*isExistentialType=*/true, fromType, fromType->isEqual(toType), toType);
20652065
return true;
20662066
}
20672067

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4256,7 +4256,7 @@ void swift::diagnoseConformanceFailure(Type T,
42564256

42574257
if (!T->isObjCExistentialType()) {
42584258
diags.diagnose(ComplainLoc, diag::type_cannot_conform, true,
4259-
T, Proto->getDeclaredType());
4259+
T, T->isEqual(Proto->getDeclaredType()), Proto->getDeclaredType());
42604260
return;
42614261
}
42624262

0 commit comments

Comments
 (0)