Skip to content

Commit 90b988f

Browse files
committed
Fix for Swift 5 compiler
1 parent bc2f0f2 commit 90b988f

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

Sources/Atoms/Core/ScopeState.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
internal final class ScopeState {
33
let token = ScopeKey.Token()
44

5+
#if !hasFeature(IsolatedDefaultValues)
6+
nonisolated init() {}
7+
#endif
8+
59
#if compiler(>=6)
610
var unregister: (@MainActor () -> Void)?
711

@@ -15,7 +19,7 @@ internal final class ScopeState {
1519
#else
1620
private var _unregister = UnsafeUncheckedSendable<(@MainActor () -> Void)?>(nil)
1721

18-
var unsubscribe: (@MainActor () -> Void)? {
22+
var unregister: (@MainActor () -> Void)? {
1923
_read { yield _unregister.value }
2024
_modify { yield &_unregister.value }
2125
}

Tests/AtomsTests/Utilities/Utilities.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,23 @@ extension TransactionState {
137137
}
138138

139139
extension Task where Success == Never, Failure == Never {
140-
static func yield(
141-
isolation: isolated (any Actor)? = #isolation,
142-
@_inheritActorContext until predicate: @Sendable () -> Bool
143-
) async {
144-
while !predicate() {
145-
await yield()
140+
#if compiler(>=6)
141+
static func yield(
142+
isolation: isolated (any Actor)? = #isolation,
143+
@_inheritActorContext until predicate: @Sendable () -> Bool
144+
) async {
145+
while !predicate() {
146+
await yield()
147+
}
146148
}
147-
}
149+
#else
150+
@MainActor
151+
static func yield(
152+
@_inheritActorContext until predicate: @Sendable () -> Bool
153+
) async {
154+
while !predicate() {
155+
await yield()
156+
}
157+
}
158+
#endif
148159
}

0 commit comments

Comments
 (0)