Skip to content

Commit ae7e24d

Browse files
authored
Merge pull request #75426 from hborla/6.0-redundant-copyable
[6.0][Conformance] Always downgrade redundant conformances to marker protocols to a warning.
2 parents e755f6e + 39345fe commit ae7e24d

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
@@ -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/Parse/inverses.swift

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

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

148148
struct Blah<T: ~Copyable>: ~Copyable {}
149149
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)