-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable Swift 6 for KDS #2771
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
base: main
Are you sure you want to change the base?
Enable Swift 6 for KDS #2771
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||
| import Synchronization | ||||||||||||||||||||||||||||
| import UIKit | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public enum InterFont: CustomFont, CaseIterable { | ||||||||||||||||||||||||||||
|
|
@@ -75,15 +76,14 @@ public enum InterFont: CustomFont, CaseIterable { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| var registeredInterfont = false | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| extension InterFont: CustomFontAccessible { | ||||||||||||||||||||||||||||
| private static let registeredInterfont = Atomic(false) | ||||||||||||||||||||||||||||
| public static var isRegistered: Bool { | ||||||||||||||||||||||||||||
| get { | ||||||||||||||||||||||||||||
| registeredInterfont | ||||||||||||||||||||||||||||
| registeredInterfont.load(ordering: .acquiring) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| set { | ||||||||||||||||||||||||||||
| registeredInterfont = newValue | ||||||||||||||||||||||||||||
| _ = registeredInterfont.exchange(newValue, ordering: .acquiringAndReleasing) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| _ = registeredInterfont.exchange(newValue, ordering: .acquiringAndReleasing) | |
| registeredInterfont.store(newValue, ordering: .releasing) |
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching the backing flag to an Atomic removes the data race on the boolean, but the overall registration flow is still not thread-safe: two callers can both observe isRegistered == false and proceed to register concurrently, potentially triggering the “calling this more than once” failure path. Consider using an atomic compare-and-swap (or another synchronization mechanism) to ensure only one thread performs registration.
| _ = registeredInterfont.exchange(newValue, ordering: .acquiringAndReleasing) | |
| if newValue { | |
| var expected = false | |
| _ = registeredInterfont.compareExchange( | |
| expected: &expected, | |
| desired: true, | |
| ordering: .acquiringAndReleasing | |
| ) | |
| } else { | |
| registeredInterfont.store(false, ordering: .releasing) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AdaptiveColoris apublicprotocol; making it inherit fromSendableis a source-breaking API change for any downstream module that conforms its own types toAdaptiveColor(those types must now beSendabletoo). If the goal is only to satisfy Swift 6 checks for KDS’s concrete color types, consider keepingAdaptiveColornon-Sendableand addingSendableonly toSemanticColor/LegacyColor(or introducing a separate internal/sendable protocol).