diff --git a/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Notifications.swift b/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Notifications.swift index 63d9b26d7a2b..79cc444fd2b1 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Notifications.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Notifications.swift @@ -24,7 +24,7 @@ struct SharedStateNotifications { @SharedReader(.screenshotCount) var screenshotCount = 0 } enum Action { - case factResponse(Result) + case factResponse(Result) case onAppear } @Dependency(\.factClient) var factClient diff --git a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Basics.swift b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Basics.swift index f1c2497ff379..1f98fbf58177 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Basics.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Basics.swift @@ -32,7 +32,7 @@ struct EffectsBasics { case decrementDelayResponse case incrementButtonTapped case numberFactButtonTapped - case numberFactResponse(Result) + case numberFactResponse(Result) } @Dependency(\.continuousClock) var clock diff --git a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Cancellation.swift b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Cancellation.swift index ce8a24fa720b..2688cca80789 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Cancellation.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Cancellation.swift @@ -25,7 +25,7 @@ struct EffectsCancellation { case cancelButtonTapped case stepperChanged(Int) case factButtonTapped - case factResponse(Result) + case factResponse(Result) } @Dependency(\.factClient) var factClient diff --git a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Refreshable.swift b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Refreshable.swift index 46271c04d6b8..48b5cccc48e9 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Refreshable.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-Refreshable.swift @@ -23,7 +23,7 @@ struct Refreshable { enum Action { case cancelButtonTapped case decrementButtonTapped - case factResponse(Result) + case factResponse(Result) case incrementButtonTapped case refresh } diff --git a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-WebSocket.swift b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-WebSocket.swift index b2e57a655943..fecec9d3c06b 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-WebSocket.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/03-Effects-WebSocket.swift @@ -29,7 +29,7 @@ struct WebSocket { case alert(PresentationAction) case connectButtonTapped case messageToSendChanged(String) - case receivedSocketMessage(Result) + case receivedSocketMessage(Result) case sendButtonTapped case sendResponse(didSucceed: Bool) case webSocket(WebSocketClient.Action) @@ -227,7 +227,7 @@ struct WebSocketClient { var open: @Sendable (_ id: ID, _ url: URL, _ protocols: [String]) async -> AsyncStream = { _, _, _ in .finished } - var receive: @Sendable (_ id: ID) async throws -> AsyncStream> + var receive: @Sendable (_ id: ID) async throws -> AsyncStream> var send: @Sendable (_ id: ID, _ message: URLSessionWebSocketTask.Message) async throws -> Void var sendPing: @Sendable (_ id: ID) async throws -> Void } @@ -295,7 +295,7 @@ extension WebSocketClient: DependencyKey { try self.socket(id: id).cancel(with: closeCode, reason: reason) } - func receive(id: ID) throws -> AsyncStream> { + func receive(id: ID) throws -> AsyncStream> { let socket = try self.socket(id: id) return AsyncStream { continuation in let task = Task { diff --git a/Examples/CaseStudies/SwiftUICaseStudies/04-NavigationStack.swift b/Examples/CaseStudies/SwiftUICaseStudies/04-NavigationStack.swift index d83b1e1e1489..ed8816753a53 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/04-NavigationStack.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/04-NavigationStack.swift @@ -190,7 +190,7 @@ struct ScreenA { case dismissButtonTapped case incrementButtonTapped case factButtonTapped - case factResponse(Result) + case factResponse(Result) } @Dependency(\.dismiss) var dismiss diff --git a/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadClient.swift b/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadClient.swift index d0395dfbdd69..c4bb1634a67b 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadClient.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadClient.swift @@ -3,7 +3,7 @@ import Foundation @DependencyClient struct DownloadClient { - var download: @Sendable (_ url: URL) -> AsyncThrowingStream = { _ in .finished() } + var download: @Sendable (_ url: URL) -> AsyncThrowingStream = { _ in .finished() } @CasePathable enum Event: Equatable { diff --git a/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadComponent.swift b/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadComponent.swift index 916e05a5d069..ce0a0454a53e 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadComponent.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ResuableOfflineDownloads/DownloadComponent.swift @@ -14,7 +14,7 @@ struct DownloadComponent { enum Action { case alert(PresentationAction) case buttonTapped - case downloadClient(Result) + case downloadClient(Result) @CasePathable enum Alert { diff --git a/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ReusableFavoriting.swift b/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ReusableFavoriting.swift index 88fa91348688..0da1c1f80877 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ReusableFavoriting.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/05-HigherOrderReducers-ReusableFavoriting.swift @@ -28,7 +28,7 @@ struct FavoritingState: Equatable { enum FavoritingAction { case alert(PresentationAction) case buttonTapped - case response(Result) + case response(Result) enum Alert: Equatable {} } diff --git a/Examples/CaseStudies/SwiftUICaseStudiesTests/03-Effects-WebSocketTests.swift b/Examples/CaseStudies/SwiftUICaseStudiesTests/03-Effects-WebSocketTests.swift index 599c115b08bd..d3d860c06fd7 100644 --- a/Examples/CaseStudies/SwiftUICaseStudiesTests/03-Effects-WebSocketTests.swift +++ b/Examples/CaseStudies/SwiftUICaseStudiesTests/03-Effects-WebSocketTests.swift @@ -6,7 +6,7 @@ import XCTest final class WebSocketTests: XCTestCase { func testWebSocketHappyPath() async { let actions = AsyncStream.makeStream(of: WebSocketClient.Action.self) - let messages = AsyncStream.makeStream(of: Result.self) + let messages = AsyncStream.makeStream(of: Result.self) let store = await TestStore(initialState: WebSocket.State()) { WebSocket() @@ -57,7 +57,7 @@ final class WebSocketTests: XCTestCase { func testWebSocketSendFailure() async { let actions = AsyncStream.makeStream(of: WebSocketClient.Action.self) - let messages = AsyncStream.makeStream(of: Result.self) + let messages = AsyncStream.makeStream(of: Result.self) let store = await TestStore(initialState: WebSocket.State()) { WebSocket() diff --git a/Examples/Search/Search/SearchView.swift b/Examples/Search/Search/SearchView.swift index 5f66125f2046..22e7b44b2694 100644 --- a/Examples/Search/Search/SearchView.swift +++ b/Examples/Search/Search/SearchView.swift @@ -31,10 +31,10 @@ struct Search { } enum Action { - case forecastResponse(GeocodingSearch.Result.ID, Result) + case forecastResponse(GeocodingSearch.Result.ID, Result) case searchQueryChanged(String) case searchQueryChangeDebounced - case searchResponse(Result) + case searchResponse(Result) case searchResultTapped(GeocodingSearch.Result) } diff --git a/Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Live.swift b/Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Live.swift index 36330d8a7981..3e1f36f673ff 100644 --- a/Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Live.swift +++ b/Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Live.swift @@ -26,7 +26,7 @@ extension SpeechClient: DependencyKey { private actor Speech { var audioEngine: AVAudioEngine? = nil var recognitionTask: SFSpeechRecognitionTask? = nil - var recognitionContinuation: AsyncThrowingStream.Continuation? + var recognitionContinuation: AsyncThrowingStream.Continuation? func finishTask() { self.audioEngine?.stop() @@ -37,7 +37,7 @@ private actor Speech { func startTask( request: UncheckedSendable - ) -> AsyncThrowingStream { + ) -> AsyncThrowingStream { let request = request.wrappedValue return AsyncThrowingStream { continuation in diff --git a/Examples/SpeechRecognition/SpeechRecognition/SpeechRecognition.swift b/Examples/SpeechRecognition/SpeechRecognition/SpeechRecognition.swift index 3293973c8d5b..16c42d2c0241 100644 --- a/Examples/SpeechRecognition/SpeechRecognition/SpeechRecognition.swift +++ b/Examples/SpeechRecognition/SpeechRecognition/SpeechRecognition.swift @@ -20,7 +20,7 @@ struct SpeechRecognition { enum Action { case alert(PresentationAction) case recordButtonTapped - case speech(Result) + case speech(Result) case speechRecognizerAuthorizationStatusResponse(SFSpeechRecognizerAuthorizationStatus) enum Alert: Equatable {} diff --git a/Examples/SyncUps/SyncUps/Dependencies/SpeechRecognizer.swift b/Examples/SyncUps/SyncUps/Dependencies/SpeechRecognizer.swift index 4f62f1a07b02..c415b9c4d47d 100644 --- a/Examples/SyncUps/SyncUps/Dependencies/SpeechRecognizer.swift +++ b/Examples/SyncUps/SyncUps/Dependencies/SpeechRecognizer.swift @@ -137,11 +137,11 @@ private actor Speech { private var audioEngine: AVAudioEngine? = nil private var recognitionTask: SFSpeechRecognitionTask? = nil private var recognitionContinuation: - AsyncThrowingStream.Continuation? + AsyncThrowingStream.Continuation? func startTask( request: SFSpeechAudioBufferRecognitionRequest - ) -> AsyncThrowingStream { + ) -> AsyncThrowingStream { AsyncThrowingStream { continuation in self.recognitionContinuation = continuation let audioSession = AVAudioSession.sharedInstance() diff --git a/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift b/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift index 87223b7dcd76..680412ca6216 100644 --- a/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift +++ b/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift @@ -19,7 +19,7 @@ public struct Login: Sendable { public enum Action: Sendable, ViewAction { case alert(PresentationAction) - case loginResponse(Result) + case loginResponse(Result) case twoFactor(PresentationAction) case view(View) diff --git a/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift b/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift index bc2586da0ceb..1c2caf78dc65 100644 --- a/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift +++ b/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift @@ -20,7 +20,7 @@ public struct TwoFactor: Sendable { public enum Action: Sendable, ViewAction { case alert(PresentationAction) - case twoFactorResponse(Result) + case twoFactorResponse(Result) case view(View) public enum Alert: Equatable, Sendable {} diff --git a/Examples/VoiceMemos/VoiceMemos/AudioPlayerClient/LiveAudioPlayerClient.swift b/Examples/VoiceMemos/VoiceMemos/AudioPlayerClient/LiveAudioPlayerClient.swift index ece4954c7a41..03bb11316050 100644 --- a/Examples/VoiceMemos/VoiceMemos/AudioPlayerClient/LiveAudioPlayerClient.swift +++ b/Examples/VoiceMemos/VoiceMemos/AudioPlayerClient/LiveAudioPlayerClient.swift @@ -3,7 +3,7 @@ import Dependencies extension AudioPlayerClient: DependencyKey { static let liveValue = Self { url in - let stream = AsyncThrowingStream { continuation in + let stream = AsyncThrowingStream { continuation in do { let delegate = try Delegate( url: url, @@ -48,7 +48,7 @@ private final class Delegate: NSObject, AVAudioPlayerDelegate, Sendable { self.didFinishPlaying(flag) } - func audioPlayerDecodeErrorDidOccur(_ player: AVAudioPlayer, error: Error?) { + func audioPlayerDecodeErrorDidOccur(_ player: AVAudioPlayer, error: (any Error)?) { self.decodeErrorDidOccur(error) } } diff --git a/Examples/VoiceMemos/VoiceMemos/AudioRecorderClient/LiveAudioRecorderClient.swift b/Examples/VoiceMemos/VoiceMemos/AudioRecorderClient/LiveAudioRecorderClient.swift index 5aedb6b1dd38..71209a5c0f68 100644 --- a/Examples/VoiceMemos/VoiceMemos/AudioRecorderClient/LiveAudioRecorderClient.swift +++ b/Examples/VoiceMemos/VoiceMemos/AudioRecorderClient/LiveAudioRecorderClient.swift @@ -37,7 +37,7 @@ private actor AudioRecorder { func start(url: URL) async throws -> Bool { self.stop() - let stream = AsyncThrowingStream { continuation in + let stream = AsyncThrowingStream { continuation in do { self.delegate = Delegate( didFinishRecording: { flag in @@ -83,11 +83,11 @@ private actor AudioRecorder { private final class Delegate: NSObject, AVAudioRecorderDelegate, Sendable { let didFinishRecording: @Sendable (Bool) -> Void - let encodeErrorDidOccur: @Sendable (Error?) -> Void + let encodeErrorDidOccur: @Sendable ((any Error)?) -> Void init( didFinishRecording: @escaping @Sendable (Bool) -> Void, - encodeErrorDidOccur: @escaping @Sendable (Error?) -> Void + encodeErrorDidOccur: @escaping @Sendable ((any Error)?) -> Void ) { self.didFinishRecording = didFinishRecording self.encodeErrorDidOccur = encodeErrorDidOccur @@ -97,7 +97,7 @@ private final class Delegate: NSObject, AVAudioRecorderDelegate, Sendable { self.didFinishRecording(flag) } - func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) { + func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: (any Error)?) { self.encodeErrorDidOccur(error) } } diff --git a/Examples/VoiceMemos/VoiceMemos/RecordingMemo.swift b/Examples/VoiceMemos/VoiceMemos/RecordingMemo.swift index 5de28b8482ef..56a5a93680c0 100644 --- a/Examples/VoiceMemos/VoiceMemos/RecordingMemo.swift +++ b/Examples/VoiceMemos/VoiceMemos/RecordingMemo.swift @@ -17,7 +17,7 @@ struct RecordingMemo { } enum Action: Sendable { - case audioRecorderDidFinish(Result) + case audioRecorderDidFinish(Result) case delegate(Delegate) case finalRecordingTime(TimeInterval) case onTask @@ -26,7 +26,7 @@ struct RecordingMemo { @CasePathable enum Delegate: Sendable { - case didFinish(Result) + case didFinish(Result) } } diff --git a/Examples/VoiceMemos/VoiceMemos/VoiceMemo.swift b/Examples/VoiceMemos/VoiceMemos/VoiceMemo.swift index b5c07d6a49d3..7c0c9a4201e5 100644 --- a/Examples/VoiceMemos/VoiceMemos/VoiceMemo.swift +++ b/Examples/VoiceMemos/VoiceMemos/VoiceMemo.swift @@ -22,7 +22,7 @@ struct VoiceMemo { } enum Action { - case audioPlayerClient(Result) + case audioPlayerClient(Result) case delegate(Delegate) case playButtonTapped case timerUpdated(TimeInterval) diff --git a/Package.swift b/Package.swift index 676d72279e46..75bc0c9e4ac8 100644 --- a/Package.swift +++ b/Package.swift @@ -91,6 +91,7 @@ let package = Package( target.swiftSettings = target.swiftSettings ?? [] target.swiftSettings?.append(contentsOf: [ .enableExperimentalFeature("StrictConcurrency"), + .enableUpcomingFeature("ExistentialAny"), .enableUpcomingFeature("InferSendableFromCaptures"), ]) } diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index 8a4d03fe3ebe..b4b75dc273c0 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -87,8 +87,14 @@ let package = Package( swiftLanguageModes: [.v6] ) -for target in package.targets where target.type == .system || target.type == .test { +for target in package.targets { target.swiftSettings = target.swiftSettings ?? [] + target.swiftSettings?.append(contentsOf: [ + .enableUpcomingFeature("ExistentialAny"), + ]) +} + +for target in package.targets where target.type == .system || target.type == .test { target.swiftSettings?.append(contentsOf: [ .swiftLanguageMode(.v5), .enableExperimentalFeature("StrictConcurrency"), diff --git a/Sources/ComposableArchitecture/Effect.swift b/Sources/ComposableArchitecture/Effect.swift index bf25c8b38b38..4c5669705faf 100644 --- a/Sources/ComposableArchitecture/Effect.swift +++ b/Sources/ComposableArchitecture/Effect.swift @@ -83,7 +83,7 @@ extension Effect { public static func run( priority: TaskPriority? = nil, operation: @escaping @Sendable (_ send: Send) async throws -> Void, - catch handler: (@Sendable (_ error: Error, _ send: Send) async -> Void)? = nil, + catch handler: (@Sendable (_ error: any Error, _ send: Send) async -> Void)? = nil, fileID: StaticString = #fileID, filePath: StaticString = #filePath, line: UInt = #line, diff --git a/Sources/ComposableArchitecture/Effects/Animation.swift b/Sources/ComposableArchitecture/Effects/Animation.swift index a69c6369f819..7b46866dead4 100644 --- a/Sources/ComposableArchitecture/Effects/Animation.swift +++ b/Sources/ComposableArchitecture/Effects/Animation.swift @@ -83,7 +83,7 @@ private struct TransactionPublisher: Publisher { self.transaction = transaction } - func receive(subscription: Subscription) { + func receive(subscription: any Subscription) { self.downstream.receive(subscription: subscription) } diff --git a/Sources/ComposableArchitecture/Effects/Cancellation.swift b/Sources/ComposableArchitecture/Effects/Cancellation.swift index 7146ed95bbc1..3b00c32f6bca 100644 --- a/Sources/ComposableArchitecture/Effects/Cancellation.swift +++ b/Sources/ComposableArchitecture/Effects/Cancellation.swift @@ -172,7 +172,7 @@ extension Effect { ) async rethrows -> T { @Dependency(\.navigationIDPath) var navigationIDPath - let (cancellable, task): (AnyCancellable, Task) = + let (cancellable, task): (AnyCancellable, Task) = _cancellationCancellables .withValue { if cancelInFlight { @@ -191,7 +191,7 @@ extension Effect { do { return try await task.cancellableValue } catch { - return try Result.failure(error)._rethrowGet() + return try Result.failure(error)._rethrowGet() } } #else @@ -203,7 +203,7 @@ extension Effect { ) async rethrows -> T { @Dependency(\.navigationIDPath) var navigationIDPath - let (cancellable, task): (AnyCancellable, Task) = + let (cancellable, task): (AnyCancellable, Task) = _cancellationCancellables .withValue { if cancelInFlight { @@ -222,7 +222,7 @@ extension Effect { do { return try await task.cancellableValue } catch { - return try Result.failure(error)._rethrowGet() + return try Result.failure(error)._rethrowGet() } } #endif diff --git a/Sources/ComposableArchitecture/Effects/TaskResult.swift b/Sources/ComposableArchitecture/Effects/TaskResult.swift index 83b4d71cf7ba..7c5a0e86d941 100644 --- a/Sources/ComposableArchitecture/Effects/TaskResult.swift +++ b/Sources/ComposableArchitecture/Effects/TaskResult.swift @@ -4,7 +4,7 @@ /// /// This type is needed because Swift's concurrency tools can only express untyped errors, such as /// `async` functions and `AsyncSequence`, and so their output can realistically only be bridged to -/// `Result<_, Error>`. However, `Result<_, Error>` is never `Equatable` since `Error` is not +/// `Result<_, any Error>`. However, `Result<_, any Error>` is never `Equatable` since `Error` is not /// `Equatable`, and equatability is very important for testing in the Composable Architecture. By /// defining our own type we get the ability to recover equatability in most situations. /// @@ -129,7 +129,7 @@ public enum TaskResult: Sendable { case success(Success) /// A failure, storing an error. - case failure(Error) + case failure(any Error) /// Creates a new task result by evaluating an async throwing closure, capturing the returned /// value as a success, or any thrown error as a failure. @@ -226,7 +226,7 @@ extension TaskResult: CasePathable { ) } - public var failure: AnyCasePath { + public var failure: AnyCasePath { AnyCasePath( embed: { .failure($0) }, extract: { @@ -238,7 +238,7 @@ extension TaskResult: CasePathable { } } -extension Result where Success: Sendable, Failure == Error { +extension Result where Success: Sendable, Failure == any Error { /// Transforms a `TaskResult` into a `Result`. /// /// - Parameter result: A task result. diff --git a/Sources/ComposableArchitecture/Internal/Create.swift b/Sources/ComposableArchitecture/Internal/Create.swift index 143d07bc2da6..67e9355f1aff 100644 --- a/Sources/ComposableArchitecture/Internal/Create.swift +++ b/Sources/ComposableArchitecture/Internal/Create.swift @@ -105,13 +105,13 @@ final class DemandBuffer: @unchecked Sendable { extension AnyPublisher where Failure == Never { private init( - _ callback: @escaping @Sendable (Effect.Subscriber) -> Cancellable + _ callback: @escaping @Sendable (Effect.Subscriber) -> any Cancellable ) { self = Publishers.Create(callback: callback).eraseToAnyPublisher() } static func create( - _ factory: @escaping @Sendable (Effect.Subscriber) -> Cancellable + _ factory: @escaping @Sendable (Effect.Subscriber) -> any Cancellable ) -> AnyPublisher { AnyPublisher(factory) } @@ -121,9 +121,9 @@ extension Publishers { fileprivate final class Create: Publisher, Sendable { typealias Failure = Never - private let callback: @Sendable (Effect.Subscriber) -> Cancellable + private let callback: @Sendable (Effect.Subscriber) -> any Cancellable - init(callback: @escaping @Sendable (Effect.Subscriber) -> Cancellable) { + init(callback: @escaping @Sendable (Effect.Subscriber) -> any Cancellable) { self.callback = callback } @@ -137,10 +137,10 @@ extension Publishers.Create { fileprivate final class Subscription: Combine.Subscription, Sendable where Downstream.Input == Output, Downstream.Failure == Never { private let buffer: DemandBuffer - private let cancellable = LockIsolated(nil) + private let cancellable = LockIsolated<(any Cancellable)?>(nil) init( - callback: @escaping @Sendable (Effect.Subscriber) -> Cancellable, + callback: @escaping @Sendable (Effect.Subscriber) -> any Cancellable, downstream: Downstream ) { self.buffer = DemandBuffer(subscriber: downstream) diff --git a/Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift b/Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift index f306b47c26e8..cef2fecf8d9c 100644 --- a/Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift +++ b/Sources/ComposableArchitecture/Internal/KeyPath+Sendable.swift @@ -1,12 +1,12 @@ #if compiler(>=6) - public typealias _AnyKeyPath = AnyKeyPath & Sendable - public typealias _PartialKeyPath = PartialKeyPath & Sendable - public typealias _KeyPath = KeyPath & Sendable - public typealias _WritableKeyPath = WritableKeyPath & Sendable - public typealias _ReferenceWritableKeyPath = ReferenceWritableKeyPath + public typealias _AnyKeyPath = any AnyKeyPath & Sendable + public typealias _PartialKeyPath = any PartialKeyPath & Sendable + public typealias _KeyPath = any KeyPath & Sendable + public typealias _WritableKeyPath = any WritableKeyPath & Sendable + public typealias _ReferenceWritableKeyPath = any ReferenceWritableKeyPath & Sendable - public typealias _PartialCaseKeyPath = PartialCaseKeyPath & Sendable - public typealias _CaseKeyPath = CaseKeyPath & Sendable + public typealias _PartialCaseKeyPath = any PartialCaseKeyPath & Sendable + public typealias _CaseKeyPath = any CaseKeyPath & Sendable #else public typealias _AnyKeyPath = AnyKeyPath public typealias _PartialKeyPath = PartialKeyPath diff --git a/Sources/ComposableArchitecture/Observation/ObservableState.swift b/Sources/ComposableArchitecture/Observation/ObservableState.swift index 0babd21cacf1..253474add19c 100644 --- a/Sources/ComposableArchitecture/Observation/ObservableState.swift +++ b/Sources/ComposableArchitecture/Observation/ObservableState.swift @@ -154,7 +154,7 @@ guard !_isPOD(T.self) else { return false } func openCollection(_ lhs: C, _ rhs: Any) -> Bool { - guard C.Element.self is ObservableState.Type else { + guard C.Element.self is any ObservableState.Type else { return false } diff --git a/Sources/ComposableArchitecture/Observation/ObservationStateRegistrar.swift b/Sources/ComposableArchitecture/Observation/ObservationStateRegistrar.swift index ecd94d760644..c63256b983f2 100644 --- a/Sources/ComposableArchitecture/Observation/ObservationStateRegistrar.swift +++ b/Sources/ComposableArchitecture/Observation/ObservationStateRegistrar.swift @@ -16,8 +16,8 @@ extension ObservationStateRegistrar: Equatable, Hashable, Codable { public static func == (_: Self, _: Self) -> Bool { true } public func hash(into hasher: inout Hasher) {} - public init(from decoder: Decoder) throws { self.init() } - public func encode(to encoder: Encoder) throws {} + public init(from decoder: any Decoder) throws { self.init() } + public func encode(to encoder: any Encoder) throws {} } #if canImport(Observation) diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift b/Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift index 06a858f52214..5c41179b0778 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift @@ -202,7 +202,7 @@ extension PresentationState: Hashable where State: Hashable { extension PresentationState: Sendable where State: Sendable {} extension PresentationState: Decodable where State: Decodable { - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { do { self.init(wrappedValue: try decoder.singleValueContainer().decode(State.self)) } catch { @@ -212,7 +212,7 @@ extension PresentationState: Decodable where State: Decodable { } extension PresentationState: Encodable where State: Encodable { - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { do { var container = encoder.singleValueContainer() try container.encode(self.wrappedValue) diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/SignpostReducer.swift b/Sources/ComposableArchitecture/Reducer/Reducers/SignpostReducer.swift index 2452ae8ffecc..aa32beaed479 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/SignpostReducer.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/SignpostReducer.swift @@ -166,7 +166,7 @@ func debugCaseOutput( } } - return (value as? CustomDebugStringConvertible)?.debugDescription + return (value as? any CustomDebugStringConvertible)?.debugDescription ?? "\(abbreviated ? "" : typeName(type(of: value)))\(debugCaseOutputHelp(value))" } diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift b/Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift index 8d13b6acbdc1..9a0675a410d2 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift @@ -210,14 +210,14 @@ extension StackState: Hashable where Element: Hashable { extension StackState: Sendable where Element: Sendable {} extension StackState: Decodable where Element: Decodable { - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let elements = try [Element](from: decoder) self.init(elements) } } extension StackState: Encodable where Element: Encodable { - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { try [Element](self).encode(to: encoder) } } diff --git a/Sources/ComposableArchitecture/SharedState/SharedReader.swift b/Sources/ComposableArchitecture/SharedState/SharedReader.swift index 7aa434f02139..83deae4fd8ba 100644 --- a/Sources/ComposableArchitecture/SharedState/SharedReader.swift +++ b/Sources/ComposableArchitecture/SharedState/SharedReader.swift @@ -166,7 +166,7 @@ extension SharedReader: Identifiable where Value: Identifiable { } extension SharedReader: Encodable where Value: Encodable { - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { do { var container = encoder.singleValueContainer() try container.encode(self.wrappedValue) diff --git a/Sources/ComposableArchitecture/Store.swift b/Sources/ComposableArchitecture/Store.swift index 5ef9a96e02b2..7bfd13952898 100644 --- a/Sources/ComposableArchitecture/Store.swift +++ b/Sources/ComposableArchitecture/Store.swift @@ -416,7 +416,7 @@ public final class Store { } } - if let stateType = State.self as? ObservableState.Type { + if let stateType = State.self as? any ObservableState.Type { self.parentCancellable = subscribeToDidSet(stateType) } #endif diff --git a/Sources/ComposableArchitecture/SwiftUI/Binding.swift b/Sources/ComposableArchitecture/SwiftUI/Binding.swift index 7335f8837021..f7d576a5cd40 100644 --- a/Sources/ComposableArchitecture/SwiftUI/Binding.swift +++ b/Sources/ComposableArchitecture/SwiftUI/Binding.swift @@ -96,7 +96,7 @@ extension BindingState: Hashable where Value: Hashable { } extension BindingState: Decodable where Value: Decodable { - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { do { let container = try decoder.singleValueContainer() self.init(wrappedValue: try container.decode(Value.self)) @@ -107,7 +107,7 @@ extension BindingState: Decodable where Value: Decodable { } extension BindingState: Encodable where Value: Encodable { - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { do { var container = encoder.singleValueContainer() try container.encode(self.wrappedValue) diff --git a/Sources/ComposableArchitecture/TestStore.swift b/Sources/ComposableArchitecture/TestStore.swift index 2842fec18810..bfaaf15264b9 100644 --- a/Sources/ComposableArchitecture/TestStore.swift +++ b/Sources/ComposableArchitecture/TestStore.swift @@ -131,7 +131,7 @@ import IssueReporting /// /// enum Action { /// case queryChanged(String) -/// case searchResponse(Result<[String], Error>) +/// case searchResponse(Result<[String], any Error>) /// } /// /// @Dependency(\.apiClient) var apiClient diff --git a/Sources/ComposableArchitecture/UIKit/IfLetUIKit.swift b/Sources/ComposableArchitecture/UIKit/IfLetUIKit.swift index 5260f356a0e8..93dda83a0cbb 100644 --- a/Sources/ComposableArchitecture/UIKit/IfLetUIKit.swift +++ b/Sources/ComposableArchitecture/UIKit/IfLetUIKit.swift @@ -48,7 +48,7 @@ extension Store { public func ifLet( then unwrap: @escaping (_ store: Store) -> Void, else: @escaping () -> Void = {} - ) -> Cancellable where State == Wrapped? { + ) -> any Cancellable where State == Wrapped? { return self .publisher .removeDuplicates(by: { ($0 != nil) == ($1 != nil) }) diff --git a/Sources/ComposableArchitecture/ViewStore.swift b/Sources/ComposableArchitecture/ViewStore.swift index 3a302e2db3d6..064231780fe1 100644 --- a/Sources/ComposableArchitecture/ViewStore.swift +++ b/Sources/ComposableArchitecture/ViewStore.swift @@ -301,7 +301,7 @@ public final class ViewStore: ObservableObject { /// } /// enum Action { /// case pulledToRefresh - /// case receivedResponse(Result) + /// case receivedResponse(Result) /// } /// @Dependency(\.fetch) var fetch /// @@ -403,7 +403,7 @@ public final class ViewStore: ObservableObject { try? await withTaskCancellationHandler { try Task.checkCancellation() try await withUnsafeThrowingContinuation { - (continuation: UnsafeContinuation) in + (continuation: UnsafeContinuation) in guard !Task.isCancelled else { continuation.resume(throwing: CancellationError()) return diff --git a/Sources/ComposableArchitectureMacros/Extensions.swift b/Sources/ComposableArchitectureMacros/Extensions.swift index 8bc7b22f4e7c..4ea0547a000b 100644 --- a/Sources/ComposableArchitectureMacros/Extensions.swift +++ b/Sources/ComposableArchitectureMacros/Extensions.swift @@ -136,7 +136,7 @@ extension TypeSyntax { genericParameters[parameter.name.text] = parameter.inheritedType } } - var iterator = self.asProtocol(TypeSyntaxProtocol.self).tokens(viewMode: .sourceAccurate) + var iterator = self.asProtocol((any TypeSyntaxProtocol).self).tokens(viewMode: .sourceAccurate) .makeIterator() guard let base = iterator.next() else { return nil diff --git a/Sources/ComposableArchitectureMacros/ObservableStateMacro.swift b/Sources/ComposableArchitectureMacros/ObservableStateMacro.swift index 16c782519c4e..858fa7e8a1e0 100644 --- a/Sources/ComposableArchitectureMacros/ObservableStateMacro.swift +++ b/Sources/ComposableArchitectureMacros/ObservableStateMacro.swift @@ -230,7 +230,7 @@ extension ObservableStateMacro: MemberMacro { return try enumExpansion(of: node, providingMembersOf: declaration, in: context) } - guard let identified = declaration.asProtocol(NamedDeclSyntax.self) else { + guard let identified = declaration.asProtocol((any NamedDeclSyntax).self) else { return [] } diff --git a/Sources/ComposableArchitectureMacros/Plugins.swift b/Sources/ComposableArchitectureMacros/Plugins.swift index 6bed7ad3a40f..5df4c81d785b 100644 --- a/Sources/ComposableArchitectureMacros/Plugins.swift +++ b/Sources/ComposableArchitectureMacros/Plugins.swift @@ -3,7 +3,7 @@ import SwiftSyntaxMacros @main struct MacrosPlugin: CompilerPlugin { - let providingMacros: [Macro.Type] = [ + let providingMacros: [any Macro.Type] = [ ObservableStateMacro.self, ObservationStateTrackedMacro.self, ObservationStateIgnoredMacro.self, diff --git a/Sources/swift-composable-architecture-benchmark/Common.swift b/Sources/swift-composable-architecture-benchmark/Common.swift index eba6f154853e..55aab0367c53 100644 --- a/Sources/swift-composable-architecture-benchmark/Common.swift +++ b/Sources/swift-composable-architecture-benchmark/Common.swift @@ -15,7 +15,7 @@ extension BenchmarkSuite { struct Benchmarking: AnyBenchmark { let name: String - let settings: [BenchmarkSetting] = [] + let settings: [any BenchmarkSetting] = [] private let _run: () throws -> Void private let _setUp: () -> Void private let _tearDown: () -> Void diff --git a/Tests/ComposableArchitectureTests/StoreTests.swift b/Tests/ComposableArchitectureTests/StoreTests.swift index 93189b755f53..ae58b156fd45 100644 --- a/Tests/ComposableArchitectureTests/StoreTests.swift +++ b/Tests/ComposableArchitectureTests/StoreTests.swift @@ -560,7 +560,7 @@ final class StoreTests: BaseTCATestCase { @available(*, deprecated) @MainActor func testScopeCancellation() async throws { - let neverEndingTask = Task { try await Task.never() } + let neverEndingTask = Task { try await Task.never() } let store = Store(initialState: ()) { Reduce { _, _ in