Skip to content

Improve -require-explicit-sendable check to account for @_nonSendable #40439

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
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
9 changes: 7 additions & 2 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,13 @@ void swift::diagnoseMissingExplicitSendable(NominalTypeDecl *nominal) {
if (!proto)
return;

SmallVector<ProtocolConformance *, 2> conformances;
if (nominal->lookupConformance(proto, conformances))
// Look for a conformance. If it's present and not (directly) missing,
// we're done.
auto conformance = nominal->getParentModule()->lookupConformance(
nominal->getDeclaredInterfaceType(), proto, /*allowMissing=*/true);
if (conformance &&
!(isa<BuiltinProtocolConformance>(conformance.getConcrete()) &&
cast<BuiltinProtocolConformance>(conformance.getConcrete())->isMissing()))
return;

// Diagnose it.
Expand Down
2 changes: 2 additions & 0 deletions test/Concurrency/require-explicit-sendable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ public struct S10 { // expected-warning{{public struct 'S10' does not specify wh
struct S11: Sendable {
var s7: S7 // expected-warning{{stored property 's7' of 'Sendable'-conforming struct 'S11' has non-sendable type 'S7'}}
}

@_nonSendable public struct S12 { }