Skip to content

Commit 5eb16ad

Browse files
committed
[Conformance] Always downgrade redundant conformances to marker protocols to
a warning. Previous compiler versions allowed this, so we should stage the change in as a warning. This was already a warning across modules, so this change only impacts redundant conformances to marker protocols within a module. This code also isn't particularly harmful, because marker protocols don't have requirements, so there isn't the same risk of unexpected behavior as other redundant conformances.
1 parent 69b2435 commit 5eb16ad

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6276,7 +6276,7 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
62766276
}
62776277

62786278
if ((existingModule != dc->getParentModule() && conformanceInOrigModule) ||
6279-
isSendable) {
6279+
diag.Protocol->isMarkerProtocol()) {
62806280
// Warn about the conformance.
62816281
if (isSendable && SendableConformance &&
62826282
isa<InheritedProtocolConformance>(SendableConformance)) {

test/decl/protocol/conforms/redundant_conformance.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ class Class3 {
8686
class SomeMockClass: Class3.ProviderThree { // okay
8787
var someInt: Int = 5
8888
}
89+
90+
91+
class ImplicitCopyable {}
92+
93+
class InheritImplicitCopyable: ImplicitCopyable, Copyable {}
94+
// expected-warning@-1 {{redundant conformance of 'InheritImplicitCopyable' to protocol 'Copyable'}}
95+
// expected-note@-2 {{'InheritImplicitCopyable' inherits conformance to protocol 'Copyable' from superclass here}}

0 commit comments

Comments
 (0)