Skip to content

Commit 42277cf

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. (cherry picked from commit 5eb16ad)
1 parent cab91dc commit 42277cf

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
@@ -6283,7 +6283,7 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
62836283
}
62846284

62856285
if ((existingModule != dc->getParentModule() && conformanceInOrigModule) ||
6286-
isSendable) {
6286+
diag.Protocol->isMarkerProtocol()) {
62876287
// Warn about the conformance.
62886288
if (isSendable && SendableConformance &&
62896289
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)