Skip to content

Commit 1527139

Browse files
authored
Merge pull request #75425 from hborla/redundant-copyable
[Conformance] Always downgrade redundant conformances to marker protocols to a warning.
2 parents 75fa43e + 286bdeb commit 1527139

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
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/Parse/inverses.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct Burrito<Filling: ~Copyable>: ~Copyable {}
140140
extension Burrito: Alias {} // expected-error {{conformance to 'Copyable' must be declared in a separate extension}}
141141
// expected-note@-1 {{'Burrito<Filling>' declares conformance to protocol 'Copyable' here}}
142142

143-
extension Burrito: Copyable & Edible & P {} // expected-error {{redundant conformance of 'Burrito<Filling>' to protocol 'Copyable'}}
143+
extension Burrito: Copyable & Edible & P {} // expected-warning {{redundant conformance of 'Burrito<Filling>' to protocol 'Copyable'}}
144144

145145
struct Blah<T: ~Copyable>: ~Copyable {}
146146
extension Blah: P, Q, Copyable, R {} // expected-error {{generic struct 'Blah' required to be 'Copyable' but is marked with '~Copyable'}}

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)