Modern Swift concurrency (breaking)#3
Merged
Merged
Conversation
068374d to
b95f5a3
Compare
…rrency
Enable the Approachable Concurrency upcoming-feature flags
(NonisolatedNonsendingByDefault, InferIsolatedConformances) across the
library, test, and E2E targets, and migrate the codebase off legacy
concurrency constructs to plain structured concurrency.
Concretely:
- Remove the downloader's GCD DispatchQueue.main.async hop and the
per-chunk Task { @mainactor in … } hops in the archive and directory
distributions, replacing them with direct, thread-safe Progress
mutation. This also removes a hazard where progress could be reported
out of order or after a stream had finished.
- Replace the two nonisolated(unsafe) statics in the test URL-protocol
mock with an OSAllocatedUnfairLock (chosen over Synchronization.Mutex,
which requires macOS 15 vs the package's macOS 13 floor).
- Modernize the manual smoke-test harness from RunLoop.main.run() to
top-level await.
Kept intentionally: UnitSlope's @unchecked Sendable (Foundation
Dimension), the @preconcurrency import ZIPFoundation lines (load-bearing
for the non-Sendable Archive), and the @preconcurrency import
RegexBuilder lines (Reference<…> is still non-Sendable; the build proved
them load-bearing).
BREAKING: JSONZipEncoder and JSONZipDecoder are now Sendable value types
(struct) instead of JSONEncoder/JSONDecoder subclasses, eliminating
their unsound @unchecked Sendable conformances. The encoder gains
init(outputFormatting: JSONEncoder.OutputFormatting = []) and a public
var outputFormatting; encode(_:) and decode(_:from:) are now value-type
methods. The no-argument JSONZipEncoder()/JSONZipDecoder() initializers
still compile, but code that subclassed these types, used them
polymorphically as JSONEncoder/JSONDecoder, or set JSONEncoder/
JSONDecoder properties other than outputFormatting must be updated.
Verified with swift build --build-tests (zero new warnings) and the full
unit-test suite (110/110 passing).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Dropping the unsound `@unchecked Sendable` on `JSONZipEncoder`/`JSONZipDecoder` (now `Sendable` value types) is source-breaking, so the previously-unreleased 3.1.0 section is promoted to 4.0.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b95f5a3 to
47cf455
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adopts the Approachable Concurrency upcoming-feature flags
(
NonisolatedNonsendingByDefault,InferIsolatedConformances) across thelibrary, test, and E2E targets, and migrates the codebase off legacy
concurrency constructs onto plain structured concurrency.
DispatchQueue.main.asynchop and the per-chunkTask { @MainActor in … }hops in the archive and directory distributions,replacing them with direct, thread-safe
Progressmutation. This also removesa hazard where progress could be reported out of order or after a stream had
finished.
nonisolated(unsafe)statics in the test URL-protocol mockwith an
OSAllocatedUnfairLock(chosen overSynchronization.Mutex, whichrequires macOS 15 vs the package's macOS 13 floor).
RunLoop.main.run()totop-level
await.Kept intentionally:
UnitSlope's@unchecked Sendable(FoundationDimension), the@preconcurrency import ZIPFoundationlines (load-bearing forthe non-
SendableArchive), and the@preconcurrency import RegexBuilderlines (
Reference<…>is still non-Sendable; the build proved themload-bearing).
Breaking changes
JSONZipEncoderandJSONZipDecoderchanged fromopenJSONEncoder/JSONDecodersubclasses marked@unchecked SendableintoSendablestructs, eliminating an unsound@uncheckedconformance on mutableclasses. The encoder gains
init(outputFormatting: JSONEncoder.OutputFormatting = [])and a public
var outputFormatting;encode(_:)anddecode(_:from:)are nowvalue-type methods.
This is source-breaking for anyone who:
JSONZipEncoder/JSONZipDecoder,JSONEncoder/JSONDecoder, orJSONEncoder/JSONDecoderproperties other thanoutputFormatting.The no-argument
JSONZipEncoder()/JSONZipDecoder()initializers stillcompile.
Verification
swift build --build-testssucceeds with zero new warnings.SwiftNASR_E2Eexecutable target was run end-to-end against live FAAdata and passed.
Version
This change set includes a source-breaking change —
JSONZipEncoderandJSONZipDecoderare nowSendablevalue types (struct) instead ofJSONEncoder/JSONDecodersubclasses. The previously-unreleased[3.1.0]CHANGELOG section (which had only additive changes) has therefore been promoted
to
[4.0.0], folding in those pending additions plus this migration. TheGitHub release will be cut after merge.