Skip to content

[BitwiseCopyable] Remove existential conformance. #71458

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
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
10 changes: 9 additions & 1 deletion lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,16 @@ bool
ExistentialConformsToSelfRequest::evaluate(Evaluator &evaluator,
ProtocolDecl *decl) const {
// Marker protocols always self-conform.
if (decl->isMarkerProtocol())
if (decl->isMarkerProtocol()) {
// Except for BitwiseCopyable an existential of which is non-trivial.
auto *bitwiseCopyableProtocol =
decl->getASTContext().getProtocol(KnownProtocolKind::BitwiseCopyable);
if (decl->getASTContext().LangOpts.hasFeature(Feature::BitwiseCopyable) &&
decl == bitwiseCopyableProtocol) {
return false;
}
return true;
}

// Otherwise, if it's not @objc, it conforms to itself only if it has a
// self-conformance witness table.
Expand Down
4 changes: 4 additions & 0 deletions test/Sema/bitwise_copyable_2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
struct S_Implicit_Nonescapable {}

struct S_Implicit_Noncopyable : ~Copyable {}

struct S_Explicit_With_Any_BitwiseCopyable : _BitwiseCopyable {
var a: any _BitwiseCopyable // expected-error {{non_bitwise_copyable_type_member}}
}