Skip to content
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

Migrate to Swift 6 language mode #172

Merged
merged 159 commits into from
Oct 19, 2024
Merged

Migrate to Swift 6 language mode #172

merged 159 commits into from
Oct 19, 2024

Conversation

fwcd
Copy link
Owner

@fwcd fwcd commented Oct 15, 2024

This bumps the required Swift version to Swift 6, which introduces data race safety via strict concurrency checking. Consequently, a larger refactoring is required.

Useful Tricks

Sendable Closures

When encounting an error like this:

182 | 
183 |                 Task {
    |                 `- error: task-isolated value of type '() async -> ()' passed as a strongly transferred parameter; later accesses could race

it has proven to be useful to mark the closure as @Sendable to get a better error message. After issues have been fixed, the annotation can be removed (for clarity/readability) since sendability can be inferred.

Note

In cases where @preconcurrency imports are used, the same trick may have to be applied again once the libraries have been updated if the annotation is removed, since the closures may implicitly become non-sendable again.

Shared Mutability

Classes with interior mutability are usually best modeled as actors.

@fwcd fwcd added the refactoring Improvements to the code structure label Oct 15, 2024
@fwcd fwcd force-pushed the swift-6-mode branch 2 times, most recently from 101e934 to 1177fd1 Compare October 15, 2024 16:33
@fwcd fwcd marked this pull request as ready for review October 19, 2024 21:58
fwcd added 2 commits October 20, 2024 00:16
The tests had to be updated since they largely operate in a nonisolated
context while most of the commands are now on the CommandActor.
@fwcd fwcd mentioned this pull request Oct 19, 2024
@fwcd fwcd merged commit ab7b03c into main Oct 19, 2024
3 checks passed
@fwcd fwcd deleted the swift-6-mode branch October 19, 2024 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improvements to the code structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant