Skip to content

[6.0][Conformance] Always downgrade redundant conformances to marker protocols to a warning. #75426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6283,7 +6283,7 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
}

if ((existingModule != dc->getParentModule() && conformanceInOrigModule) ||
isSendable) {
diag.Protocol->isMarkerProtocol()) {
// Warn about the conformance.
if (isSendable && SendableConformance &&
isa<InheritedProtocolConformance>(SendableConformance)) {
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/inverses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct Burrito<Filling: ~Copyable>: ~Copyable {}
extension Burrito: Alias {} // expected-error {{conformance to 'Copyable' must be declared in a separate extension}}
// expected-note@-1 {{'Burrito<Filling>' declares conformance to protocol 'Copyable' here}}

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

struct Blah<T: ~Copyable>: ~Copyable {}
extension Blah: P, Q, Copyable, R {} // expected-error {{generic struct 'Blah' required to be 'Copyable' but is marked with '~Copyable'}}
Expand Down
7 changes: 7 additions & 0 deletions test/decl/protocol/conforms/redundant_conformance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@ class Class3 {
class SomeMockClass: Class3.ProviderThree { // okay
var someInt: Int = 5
}


class ImplicitCopyable {}

class InheritImplicitCopyable: ImplicitCopyable, Copyable {}
// expected-warning@-1 {{redundant conformance of 'InheritImplicitCopyable' to protocol 'Copyable'}}
// expected-note@-2 {{'InheritImplicitCopyable' inherits conformance to protocol 'Copyable' from superclass here}}