Repository navigation
Build every target in Swift 6 language mode - #9
Merged
Merged
Conversation
All 11 targets move from .swiftLanguageMode(.v5) to .v6, so the compiler checks concurrency strictly. - The public value types are Sendable: Version, Value, Value.Change, Value.Fork, ZoneReference, Map nodes, Branch, SnapshotManifest, SnapshotPolicy and their nested types. The Exchange and Zone protocols require Sendable. SOURCE BREAKING for anyone with their own conformance. - Classes that hold their state under a lock, or in an actor, declare @unchecked Sendable: Store, FileZone, SQLiteZone, and the exchanges. The exchange classes are final now. - Log is Sendable. Its level is behind a Mutex, so it can be set from any thread. The global `log` needed this. - Cache is Sendable. Its generation type is a struct, which also ends the aliasing that made every generation the same object. Keys are wrapped in a Sendable box, so the methods take `some Hashable & Sendable`. - @atomic is renamed to @guarded. The standard library now has its own Atomic, and the two names clashed. Strict checking found real races in CloudKitExchange, all fixed: - Query records were collected from two callbacks with no lock. - The cached restoration state was read, changed and written back in separate steps, so concurrent callbacks could lose version IDs. - Its store property was a public var, and its temporary directory a lazy var. BoxExchange had the same lazy var. The samples build unchanged. Storage now documents that implementations must be thread-safe, because Store vouches for them.
Swift 6.1.2 rejects capturing a non-Sendable closure in the operation queue block. Swift 6.4, which I build with locally, accepts it.
Swift 6.1.2 requires the thrown error to be Sendable, and bindingFailed carried an Any?. It now carries a description string, which is what the value was used for anyway. SOURCE BREAKING for anyone matching that case.
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.
All 11 targets now build in Swift 6 language mode, so the compiler checks concurrency strictly. This was audit item 30.
Strict checking earned its keep: it found real races in
CloudKitExchange, not just annotation work.storewas a publicvar, and the temporary directory alazy var, which is not thread-safe.BoxExchangehad the samelazy var.The rest is mostly marking value types
Sendable. Classes that keep their state under a lock or in an actor declare@unchecked Sendable; a reviewer audited each of those promises against the stored properties.Two other real fixes fell out of it.
Cache's generation type is now a struct, which ends the aliasing that made every generation the same object.Log.levelis behind aMutex, so it can be set from any thread.Source breaking
ExchangeandZonerequireSendable. A custom conformance in your own code must beSendabletoo.Cachegained aValueType: Sendableconstraint, and its methods takesome Hashable & Sendableinstead ofAnyHashable.@Atomicis renamed to@Guarded. The standard library now has its ownAtomic, and the two names clashed.Both sample apps build with no changes, so ordinary use of the framework is unaffected.
208 tests pass, and
swift build --enable-all-traitsis clean.