Skip to content

Commit 9963fce

Browse files
committed
SR-11902: Fixed code review issues. Updated tests.
1 parent 7458016 commit 9963fce

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,9 +2710,10 @@ NOTE(missing_member_type_conformance_prevents_synthesis, none,
27102710
"protocol %2, preventing synthesized conformance "
27112711
"of %3 to %2",
27122712
(unsigned, Type, Type, Type))
2713-
NOTE(classes_equatable_hashable_synthesis,none,
2714-
"currently 'Equatable' and 'Hashable' synthesis is not supported for classes "
2715-
"because of inheritance.", ())
2713+
NOTE(classes_automatic_protocol_synthesis,none,
2714+
"automatic synthesis of '%0' is not supported for classes "
2715+
"because of inheritance.",
2716+
(StringRef))
27162717

27172718
// Dynamic Self
27182719
ERROR(dynamic_self_non_method,none,

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ void diagnoseFailedDerivation(DeclContext *DC, NominalTypeDecl *nominal,
168168

169169
if (auto *classDecl = dyn_cast<ClassDecl>(nominal)) {
170170
ctx.Diags.diagnose(classDecl->getLoc(),
171-
diag::classes_equatable_hashable_synthesis);
171+
diag::classes_automatic_protocol_synthesis,
172+
protocol->getName().str());
172173
}
173174
}
174175

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s
2+
3+
class Foo: Equatable {}
4+
// expected-error@-1 {{type 'Foo' does not conform to protocol 'Equatable'}} expected-note@-1 {{automatic synthesis of 'Equatable' is not supported for classes because of inheritance.}}
5+
6+
class Bar: Hashable {}
7+
// expected-error@-1 {{type 'Bar' does not conform to protocol 'Hashable'}} expected-note@-1 {{automatic synthesis of 'Hashable' is not supported for classes because of inheritance.}}
8+
// expected-error@-2 {{type 'Bar' does not conform to protocol 'Equatable'}} expected-note@-2 {{automatic synthesis of 'Equatable' is not supported for classes because of inheritance.}}

0 commit comments

Comments
 (0)