Skip to content

Commit

Permalink
Revert it back to use compiler() instead of swift()
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1028 committed Nov 19, 2024
1 parent 9e5eb27 commit d6ca10c
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Sources/Atoms/AsyncPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum AsyncPhase<Success, Failure: Error> {
}
}

#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.
///
Expand Down
6 changes: 3 additions & 3 deletions Sources/Atoms/Atom/AsyncPhaseAtom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public protocol AsyncPhaseAtom: AsyncAtom where Produced == AsyncPhase<Success,
/// The type of success value that this atom produces.
associatedtype Success

#if swift(>=6)
#if compiler(>=6)
/// The type of errors that this atom produces.
associatedtype Failure: Error

Expand Down Expand Up @@ -80,7 +80,7 @@ public extension AsyncPhaseAtom {
var producer: AtomProducer<Produced> {
AtomProducer { context in
let task = Task {
#if swift(>=6)
#if compiler(>=6)
do throws(Failure) {
let value = try await context.transaction(value)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/Core/Producer/AtomProducerContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal struct AtomProducerContext<Value> {
return body(context)
}

#if swift(>=6)
#if compiler(>=6)
func transaction<T, E: Error>(_ body: @MainActor (AtomTransactionContext) async throws(E) -> T) async throws(E) -> T {
transactionState.begin()
let context = AtomTransactionContext(store: store, transactionState: transactionState)
Expand Down
6 changes: 5 additions & 1 deletion Sources/Atoms/Core/SubscriberState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<AtomKey>()
nonisolated(unsafe) var unsubscribe: ((Set<AtomKey>) -> Void)?

#if !hasFeature(DisableOutwardActorInference)
nonisolated init() {}
#endif

// TODO: Use isolated synchronous deinit once it's available.
// 0371-isolated-synchronous-deinit
deinit {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Atoms/Modifier/ChangesOfModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Equatable>(
of keyPath: any KeyPath<Produced, T> & Sendable
) -> ModifiedAtom<Self, ChangesOfModifier<Produced, T>> {
Expand All @@ -48,7 +48,7 @@ public struct ChangesOfModifier<Base, Produced: Equatable>: 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<Base, Produced> & Sendable
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/PropertyWrapper/ViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/PropertyWrapper/Watch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct Watch<Node: Atom>: 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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Atoms/PropertyWrapper/WatchState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct WatchState<Node: StateAtom>: 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 {
Expand All @@ -64,7 +64,7 @@ public struct WatchState<Node: StateAtom>: 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<Node.Produced> {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Atoms/PropertyWrapper/WatchStateObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public struct WatchStateObject<Node: ObservableObjectAtom>: 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 {
Expand All @@ -95,7 +95,7 @@ public struct WatchStateObject<Node: ObservableObjectAtom>: 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 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AtomsTests/Atom/AsyncPhaseAtomTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Tests/AtomsTests/Utilities/TestAtom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct TestAsyncPhaseAtom<Success, Failure: Error>: AsyncPhaseAtom, @unchecked S
UniqueKey()
}

#if swift(>=6)
#if compiler(>=6)
func value(context: Context) async throws(Failure) -> Success {
try getResult().get()
}
Expand Down

0 comments on commit d6ca10c

Please sign in to comment.