diff --git a/Sources/Atoms/AsyncPhase.swift b/Sources/Atoms/AsyncPhase.swift index e354fff1..19373599 100644 --- a/Sources/Atoms/AsyncPhase.swift +++ b/Sources/Atoms/AsyncPhase.swift @@ -24,7 +24,7 @@ public enum AsyncPhase { } } - #if swift(>=6) + #if compiler(>=6) /// Creates a new phase by evaluating a async throwing closure, capturing the /// returned value as a success, or thrown error as a failure. /// diff --git a/Sources/Atoms/Atom/AsyncPhaseAtom.swift b/Sources/Atoms/Atom/AsyncPhaseAtom.swift index 7f9add20..885c2c96 100644 --- a/Sources/Atoms/Atom/AsyncPhaseAtom.swift +++ b/Sources/Atoms/Atom/AsyncPhaseAtom.swift @@ -39,7 +39,7 @@ public protocol AsyncPhaseAtom: AsyncAtom where Produced == AsyncPhase=6) + #if compiler(>=6) /// The type of errors that this atom produces. associatedtype Failure: Error @@ -80,7 +80,7 @@ public extension AsyncPhaseAtom { var producer: AtomProducer { AtomProducer { context in let task = Task { - #if swift(>=6) + #if compiler(>=6) do throws(Failure) { let value = try await context.transaction(value) @@ -119,7 +119,7 @@ public extension AsyncPhaseAtom { var phase = Produced.suspending let task = Task { - #if swift(>=6) + #if compiler(>=6) do throws(Failure) { let value = try await context.transaction(value) diff --git a/Sources/Atoms/Core/Producer/AtomProducerContext.swift b/Sources/Atoms/Core/Producer/AtomProducerContext.swift index e8ba655e..ac4d8da0 100644 --- a/Sources/Atoms/Core/Producer/AtomProducerContext.swift +++ b/Sources/Atoms/Core/Producer/AtomProducerContext.swift @@ -34,7 +34,7 @@ internal struct AtomProducerContext { return body(context) } - #if swift(>=6) + #if compiler(>=6) func transaction(_ body: @MainActor (AtomTransactionContext) async throws(E) -> T) async throws(E) -> T { transactionState.begin() let context = AtomTransactionContext(store: store, transactionState: transactionState) diff --git a/Sources/Atoms/Core/SubscriberState.swift b/Sources/Atoms/Core/SubscriberState.swift index 5b85e2b9..2a6a1aef 100644 --- a/Sources/Atoms/Core/SubscriberState.swift +++ b/Sources/Atoms/Core/SubscriberState.swift @@ -4,10 +4,14 @@ import Foundation internal final class SubscriberState { let token = SubscriberKey.Token() - #if swift(>=6) + #if compiler(>=6) nonisolated(unsafe) var subscribing = Set() nonisolated(unsafe) var unsubscribe: ((Set) -> Void)? + #if !hasFeature(DisableOutwardActorInference) + nonisolated init() {} + #endif + // TODO: Use isolated synchronous deinit once it's available. // 0371-isolated-synchronous-deinit deinit { diff --git a/Sources/Atoms/Modifier/ChangesOfModifier.swift b/Sources/Atoms/Modifier/ChangesOfModifier.swift index 77825f1c..745062e9 100644 --- a/Sources/Atoms/Modifier/ChangesOfModifier.swift +++ b/Sources/Atoms/Modifier/ChangesOfModifier.swift @@ -22,7 +22,7 @@ public extension Atom { /// - Parameter keyPath: A key path for the property of the original atom value. /// /// - Returns: An atom that provides the partial property of the original atom value. - #if swift(>=6) || hasFeature(InferSendableFromCaptures) + #if compiler(>=6) || hasFeature(InferSendableFromCaptures) func changes( of keyPath: any KeyPath & Sendable ) -> ModifiedAtom> { @@ -48,7 +48,7 @@ public struct ChangesOfModifier: AtomModifier { /// A type of value the modified atom produces. public typealias Produced = Produced - #if swift(>=6) || hasFeature(InferSendableFromCaptures) + #if compiler(>=6) || hasFeature(InferSendableFromCaptures) /// A type representing the stable identity of this modifier. public struct Key: Hashable, Sendable { private let keyPath: any KeyPath & Sendable diff --git a/Sources/Atoms/PropertyWrapper/ViewContext.swift b/Sources/Atoms/PropertyWrapper/ViewContext.swift index 39a81cfb..7c0ddaa8 100644 --- a/Sources/Atoms/PropertyWrapper/ViewContext.swift +++ b/Sources/Atoms/PropertyWrapper/ViewContext.swift @@ -44,7 +44,7 @@ public struct ViewContext: DynamicProperty { self.location = SourceLocation(fileID: fileID, line: line) } - #if swift(>=6) || hasFeature(DisableOutwardActorInference) + #if compiler(>=6) || hasFeature(DisableOutwardActorInference) @State private var signal = false @State diff --git a/Sources/Atoms/PropertyWrapper/Watch.swift b/Sources/Atoms/PropertyWrapper/Watch.swift index 6698a37d..3e57d344 100644 --- a/Sources/Atoms/PropertyWrapper/Watch.swift +++ b/Sources/Atoms/PropertyWrapper/Watch.swift @@ -40,7 +40,7 @@ public struct Watch: DynamicProperty { /// access ``wrappedValue`` directly. Instead, you use the property variable created /// with the `@Watch` attribute. /// Accessing this property starts watching the atom. - #if swift(>=6) || hasFeature(DisableOutwardActorInference) + #if compiler(>=6) || hasFeature(DisableOutwardActorInference) @MainActor #endif public var wrappedValue: Node.Produced { diff --git a/Sources/Atoms/PropertyWrapper/WatchState.swift b/Sources/Atoms/PropertyWrapper/WatchState.swift index 37897684..221716ba 100644 --- a/Sources/Atoms/PropertyWrapper/WatchState.swift +++ b/Sources/Atoms/PropertyWrapper/WatchState.swift @@ -50,7 +50,7 @@ public struct WatchState: DynamicProperty { /// with the `@WatchState` attribute. /// Accessing to the getter of this property starts watching the atom, but doesn't /// by setting a new value. - #if swift(>=6) || hasFeature(DisableOutwardActorInference) + #if compiler(>=6) || hasFeature(DisableOutwardActorInference) @MainActor #endif public var wrappedValue: Node.Produced { @@ -64,7 +64,7 @@ public struct WatchState: DynamicProperty { /// To get the ``projectedValue``, prefix the property variable with `$`. /// Accessing this property itself does not start watching the atom, but does when /// the view accesses to the getter of the binding. - #if swift(>=6) || hasFeature(DisableOutwardActorInference) + #if compiler(>=6) || hasFeature(DisableOutwardActorInference) @MainActor #endif public var projectedValue: Binding { diff --git a/Sources/Atoms/PropertyWrapper/WatchStateObject.swift b/Sources/Atoms/PropertyWrapper/WatchStateObject.swift index e6ce1b36..65919542 100644 --- a/Sources/Atoms/PropertyWrapper/WatchStateObject.swift +++ b/Sources/Atoms/PropertyWrapper/WatchStateObject.swift @@ -84,7 +84,7 @@ public struct WatchStateObject: DynamicProperty { /// access ``wrappedValue`` directly. Instead, you use the property variable created /// with the `@WatchStateObject` attribute. /// Accessing this property starts watching the atom. - #if swift(>=6) || hasFeature(DisableOutwardActorInference) + #if compiler(>=6) || hasFeature(DisableOutwardActorInference) @MainActor #endif public var wrappedValue: Node.Produced { @@ -95,7 +95,7 @@ public struct WatchStateObject: DynamicProperty { /// /// Use the projected value to pass a binding value down a view hierarchy. /// To get the projected value, prefix the property variable with `$`. - #if swift(>=6) || hasFeature(DisableOutwardActorInference) + #if compiler(>=6) || hasFeature(DisableOutwardActorInference) @MainActor #endif public var projectedValue: Wrapper { diff --git a/Tests/AtomsTests/Atom/AsyncPhaseAtomTests.swift b/Tests/AtomsTests/Atom/AsyncPhaseAtomTests.swift index 51b63a72..6d4f0ac5 100644 --- a/Tests/AtomsTests/Atom/AsyncPhaseAtomTests.swift +++ b/Tests/AtomsTests/Atom/AsyncPhaseAtomTests.swift @@ -31,7 +31,7 @@ final class AsyncPhaseAtomTests: XCTestCase { let phase = context.watch(atom) - #if swift(>=6) + #if compiler(>=6) XCTAssertEqual(phase.error, URLError(.badURL)) #else XCTAssertEqual(phase.error as? URLError, URLError(.badURL)) diff --git a/Tests/AtomsTests/Utilities/TestAtom.swift b/Tests/AtomsTests/Utilities/TestAtom.swift index 49ceca71..efde9a6b 100644 --- a/Tests/AtomsTests/Utilities/TestAtom.swift +++ b/Tests/AtomsTests/Utilities/TestAtom.swift @@ -86,7 +86,7 @@ struct TestAsyncPhaseAtom: AsyncPhaseAtom, @unchecked S UniqueKey() } - #if swift(>=6) + #if compiler(>=6) func value(context: Context) async throws(Failure) -> Success { try getResult().get() }