Skip to content

Change @_nonSendable to unavailable extensions #892

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 1 commit into from
Sep 3, 2024

Conversation

jmschonfeld
Copy link
Contributor

@_nonSendable was designed as a detail for the compiler to use and was not intended to be written directly in source. As such, the compiler treats it slightly differently and has allowed us to commit some incorrect annotations, such as:

@_nonSendable
open class FileManager : @unchecked Sendable {

(a both non-sendable and unchecked-sendable class)

and

@_nonSendable
public struct KeyPathComparator<Compared>: SortComparator {

(a non-sendable struct that conforms to a Sendable protocol)

This PR replaces usages of @_nonSendable with the officially supported design (unavailable extensions). This has the drawbacks of needing to duplicate the type's availability and moving the non-sendable annotation away from the type itself, but it means that both of the errors above would be diagnosed as actual compilation errors rather than silently being accepted and potentially causing issues for clients.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit da80d51 into swiftlang:main Sep 3, 2024
3 checks passed
@jmschonfeld jmschonfeld deleted the non-sendable-annotations branch September 3, 2024 17:47
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants