diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60f0b9b0..403e210d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,7 @@ For this reason, whenever you add new tests **you have to run a script** that ge ### Make sure your patch works for all supported versions of swift -The CI will do this for you. You can use the docker-compose files included if you wish to check locally. Currently all versions of swift >= 5.5 are supported. For example usage of docker compose see the main [README](./README.md#an-alternative-using-docker-compose) +The CI will do this for you. You can use the docker-compose files included if you wish to check locally. Currently all versions of swift >= 5.5.2 are supported. For example usage of docker compose see the main [README](./README.md#an-alternative-using-docker-compose) ### Make sure your code is performant diff --git a/README.md b/README.md index c87be607..7c738b2f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It's like [Netty](https://netty.io), but written for Swift. The SwiftNIO project is split across multiple repositories: -Repository | NIO 2 (Swift 5.5+) +Repository | NIO 2 (Swift 5.5.2+) --- | --- [https://github.com/apple/swift-nio][repo-nio]
SwiftNIO core | `from: "2.0.0"` [https://github.com/apple/swift-nio-ssl][repo-nio-ssl]
TLS (SSL) support | `from: "2.0.0"` @@ -70,14 +70,14 @@ Redis | ✅ | ❌ | [mordil/swift-redi-stack](https://gitlab.com/Mordil/swift-re This is the current version of SwiftNIO and will be supported for the foreseeable future. -The most recent versions of SwiftNIO support Swift 5.5 and newer. The minimum Swift version supported by SwiftNIO releases are detailed below: +The most recent versions of SwiftNIO support Swift 5.5.2 and newer. The minimum Swift version supported by SwiftNIO releases are detailed below: SwiftNIO | Minimum Swift Version --------------------|---------------------- `2.0.0 ..< 2.30.0` | 5.0 `2.30.0 ..< 2.40.0` | 5.2 `2.40.0 ..< 2.43.0` | 5.4 -`2.43.0 ...` | 5.5 +`2.43.0 ...` | 5.5.2 ### SwiftNIO 1 SwiftNIO 1 is considered end of life - it is strongly recommended that you move to a newer version. The Core NIO team does not actively work on this version. No new features will be added to this version but PRs which fix bugs or security vulnerabilities will be accepted until the end of May 2022. diff --git a/SECURITY.md b/SECURITY.md index 639b4e82..9dcaeb79 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -18,7 +18,7 @@ team would create the following patch releases: * NIO 2.42. + plus next patch release to address the issue for projects that support Swift 5.4 and later * mainline + plus next patch release to address the issue for projects that support - Swift 5.5 and later + Swift 5.5.2 and later SwiftNIO 1.x is considered end of life and will not receive any security patches. diff --git a/Sources/NIOAsyncAwaitDemo/AsyncChannelIO.swift b/Sources/NIOAsyncAwaitDemo/AsyncChannelIO.swift index 8e08e85a..c4e6ca69 100644 --- a/Sources/NIOAsyncAwaitDemo/AsyncChannelIO.swift +++ b/Sources/NIOAsyncAwaitDemo/AsyncChannelIO.swift @@ -15,7 +15,6 @@ import NIOCore import NIOHTTP1 -#if canImport(_Concurrency) && compiler(>=5.5.2) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) struct AsyncChannelIO { let channel: Channel @@ -39,4 +38,3 @@ struct AsyncChannelIO { try await self.channel.close() } } -#endif diff --git a/Sources/NIOAsyncAwaitDemo/main.swift b/Sources/NIOAsyncAwaitDemo/main.swift index 09a217f2..a681a628 100644 --- a/Sources/NIOAsyncAwaitDemo/main.swift +++ b/Sources/NIOAsyncAwaitDemo/main.swift @@ -16,8 +16,6 @@ import NIOPosix import NIOHTTP1 import Dispatch -#if canImport(_Concurrency) && compiler(>=5.5.2) - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func makeHTTPChannel(host: String, port: Int, group: EventLoopGroup) async throws -> AsyncChannelIO { let channel = try await ClientBootstrap(group: group).connect(host: host, port: port).get() @@ -76,6 +74,3 @@ if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) { dg.leave() } dg.wait() -#else -print("ERROR: The NIO Async Await Demo supports Swift >= 5.5.2.") -#endif diff --git a/Sources/NIOChatServer/main.swift b/Sources/NIOChatServer/main.swift index bf7062c8..e12c2c51 100644 --- a/Sources/NIOChatServer/main.swift +++ b/Sources/NIOChatServer/main.swift @@ -109,10 +109,8 @@ final class ChatHandler: ChannelInboundHandler { } } -#if swift(>=5.5) && canImport(_Concurrency) /// access to the internal state is protected by `channelsSyncQueue` extension ChatHandler: @unchecked Sendable {} -#endif // We need to share the same ChatHandler for all as it keeps track of all // connected clients. For this ChatHandler MUST be thread-safe! diff --git a/Sources/NIOConcurrencyHelpers/NIOAtomic.swift b/Sources/NIOConcurrencyHelpers/NIOAtomic.swift index 805f860d..345b5931 100644 --- a/Sources/NIOConcurrencyHelpers/NIOAtomic.swift +++ b/Sources/NIOConcurrencyHelpers/NIOAtomic.swift @@ -313,9 +313,5 @@ public final class NIOAtomic { } } -#if compiler(>=5.5) && canImport(_Concurrency) @available(*, deprecated) -extension NIOAtomic: Sendable { - -} -#endif +extension NIOAtomic: Sendable {} diff --git a/Sources/NIOConcurrencyHelpers/NIOLock.swift b/Sources/NIOConcurrencyHelpers/NIOLock.swift index 329277b7..a4ca4c02 100644 --- a/Sources/NIOConcurrencyHelpers/NIOLock.swift +++ b/Sources/NIOConcurrencyHelpers/NIOLock.swift @@ -147,7 +147,5 @@ extension NIOLock { } } -#if compiler(>=5.5) && canImport(_Concurrency) extension NIOLock: Sendable {} extension NIOLock._Storage: Sendable {} -#endif diff --git a/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift b/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift index c1ee3272..59d90606 100644 --- a/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift +++ b/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift @@ -52,7 +52,5 @@ public struct NIOLockedValueBox { } } -#if compiler(>=5.5) && canImport(_Concurrency) extension NIOLockedValueBox: Sendable where Value: Sendable {} extension NIOLockedValueBox._Storage: @unchecked Sendable {} -#endif diff --git a/Sources/NIOConcurrencyHelpers/lock.swift b/Sources/NIOConcurrencyHelpers/lock.swift index bdf50a16..4ccb0999 100644 --- a/Sources/NIOConcurrencyHelpers/lock.swift +++ b/Sources/NIOConcurrencyHelpers/lock.swift @@ -290,12 +290,6 @@ internal func debugOnly(_ body: () -> Void) { assert({ body(); return true }()) } -#if compiler(>=5.5) && canImport(_Concurrency) @available(*, deprecated) -extension Lock: Sendable { - -} -extension ConditionLock: @unchecked Sendable { - -} -#endif +extension Lock: Sendable {} +extension ConditionLock: @unchecked Sendable {} diff --git a/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift b/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift deleted file mode 100644 index a7c20d91..00000000 --- a/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift +++ /dev/null @@ -1,218 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the SwiftNIO open source project -// -// Copyright (c) 2021 Apple Inc. and the SwiftNIO project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of SwiftNIO project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -#if compiler(>=5.5) && !compiler(>=5.5.2) && canImport(_Concurrency) - -extension EventLoopFuture { - /// Get the value/error from an `EventLoopFuture` in an `async` context. - /// - /// This function can be used to bridge an `EventLoopFuture` into the `async` world. Ie. if you're in an `async` - /// function and want to get the result of this future. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @inlinable - public func get() async throws -> Value { - return try await withUnsafeThrowingContinuation { cont in - self.whenComplete { result in - switch result { - case .success(let value): - cont.resume(returning: value) - case .failure(let error): - cont.resume(throwing: error) - } - } - } - } -} - -extension EventLoopGroup { - /// Shuts down the event loop gracefully. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @inlinable - public func shutdownGracefully() async throws { - return try await withCheckedThrowingContinuation { cont in - self.shutdownGracefully { error in - if let error = error { - cont.resume(throwing: error) - } else { - cont.resume() - } - } - } - } -} - -extension EventLoopPromise { - /// Complete a future with the result (or error) of the `async` function `body`. - /// - /// This function can be used to bridge the `async` world into an `EventLoopPromise`. - /// - /// - parameters: - /// - body: The `async` function to run. - /// - returns: A `Task` which was created to `await` the `body`. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @discardableResult - @inlinable - public func completeWithTask(_ body: @escaping @Sendable () async throws -> Value) -> Task { - Task { - do { - let value = try await body() - self.succeed(value) - } catch { - self.fail(error) - } - } - } -} - -extension Channel { - /// Shortcut for calling `write` and `flush`. - /// - /// - parameters: - /// - data: the data to write - /// - promise: the `EventLoopPromise` that will be notified once the `write` operation completes, - /// or `nil` if not interested in the outcome of the operation. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @inlinable - public func writeAndFlush(_ any: T) async throws { - try await self.writeAndFlush(any).get() - } - - /// Set `option` to `value` on this `Channel`. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @inlinable - public func setOption(_ option: Option, value: Option.Value) async throws { - try await self.setOption(option, value: value).get() - } - - /// Get the value of `option` for this `Channel`. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @inlinable - public func getOption(_ option: Option) async throws -> Option.Value { - return try await self.getOption(option).get() - } -} - -extension ChannelOutboundInvoker { - /// Register on an `EventLoop` and so have all its IO handled. - /// - /// - returns: the future which will be notified once the operation completes. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func register(file: StaticString = #file, line: UInt = #line) async throws { - try await self.register(file: file, line: line).get() - } - - /// Bind to a `SocketAddress`. - /// - parameters: - /// - to: the `SocketAddress` to which we should bind the `Channel`. - /// - returns: the future which will be notified once the operation completes. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func bind(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) async throws { - try await self.bind(to: address, file: file, line: line).get() - } - - /// Connect to a `SocketAddress`. - /// - parameters: - /// - to: the `SocketAddress` to which we should connect the `Channel`. - /// - returns: the future which will be notified once the operation completes. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func connect(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) async throws { - try await self.connect(to: address, file: file, line: line).get() - } - - /// Shortcut for calling `write` and `flush`. - /// - /// - parameters: - /// - data: the data to write - /// - returns: the future which will be notified once the `write` operation completes. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func writeAndFlush(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) async throws { - try await self.writeAndFlush(data, file: file, line: line).get() - } - - /// Close the `Channel` and so the connection if one exists. - /// - /// - parameters: - /// - mode: the `CloseMode` that is used - /// - returns: the future which will be notified once the operation completes. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func close(mode: CloseMode = .all, file: StaticString = #file, line: UInt = #line) async throws { - try await self.close(mode: mode, file: file, line: line).get() - } - - /// Trigger a custom user outbound event which will flow through the `ChannelPipeline`. - /// - /// - parameters: - /// - event: the event itself. - /// - returns: the future which will be notified once the operation completes. - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #file, line: UInt = #line) async throws { - try await self.triggerUserOutboundEvent(event, file: file, line: line).get() - } -} - -extension ChannelPipeline { - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func addHandler(_ handler: ChannelHandler, - name: String? = nil, - position: ChannelPipeline.Position = .last) async throws { - try await self.addHandler(handler, name: name, position: position).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func removeHandler(_ handler: RemovableChannelHandler) async throws { - try await self.removeHandler(handler).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func removeHandler(name: String) async throws { - try await self.removeHandler(name: name).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func removeHandler(context: ChannelHandlerContext) async throws { - try await self.removeHandler(context: context).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @available(*, deprecated, message: "ChannelHandlerContext is not Sendable and it is therefore not safe to be used outside of its EventLoop") - public func context(handler: ChannelHandler) async throws -> ChannelHandlerContext { - return try await self.context(handler: handler).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @available(*, deprecated, message: "ChannelHandlerContext is not Sendable and it is therefore not safe to be used outside of its EventLoop") - public func context(name: String) async throws -> ChannelHandlerContext { - return try await self.context(name: name).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - @available(*, deprecated, message: "ChannelHandlerContext is not Sendable and it is therefore not safe to be used outside of its EventLoop") - @inlinable - public func context(handlerType: Handler.Type) async throws -> ChannelHandlerContext { - return try await self.context(handlerType: handlerType).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func addHandlers(_ handlers: [ChannelHandler], - position: ChannelPipeline.Position = .last) async throws { - try await self.addHandlers(handlers, position: position).get() - } - - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) - public func addHandlers(_ handlers: ChannelHandler..., - position: ChannelPipeline.Position = .last) async throws { - try await self.addHandlers(handlers, position: position) - } -} -#endif diff --git a/Sources/NIOCore/AsyncAwaitSupport.swift b/Sources/NIOCore/AsyncAwaitSupport.swift index 1405ff2e..5c76d249 100644 --- a/Sources/NIOCore/AsyncAwaitSupport.swift +++ b/Sources/NIOCore/AsyncAwaitSupport.swift @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) - extension EventLoopFuture { /// Get the value/error from an `EventLoopFuture` in an `async` context. /// @@ -332,5 +330,3 @@ struct AsyncSequenceFromIterator: AsyncSeq self.iterator } } - -#endif diff --git a/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducer.swift b/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducer.swift index f3346955..2022aa79 100644 --- a/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducer.swift +++ b/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducer.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) import DequeModule import NIOConcurrencyHelpers @@ -329,4 +328,4 @@ extension NIOAsyncSequenceProducer { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @available(*, unavailable) extension NIOAsyncSequenceProducer.AsyncIterator: Sendable {} -#endif + diff --git a/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift b/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift index 2176a65c..5fe444b9 100644 --- a/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift +++ b/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) public enum NIOAsyncSequenceProducerBackPressureStrategies { /// A high-low watermarked back-pressure strategy for a ``NIOAsyncSequenceProducer``. /// @@ -46,4 +45,3 @@ public enum NIOAsyncSequenceProducerBackPressureStrategies { } } } -#endif diff --git a/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift b/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift index 8f9306eb..f7a70dab 100644 --- a/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift +++ b/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) import Atomics import DequeModule import NIOConcurrencyHelpers @@ -1065,4 +1064,3 @@ extension NIOAsyncWriter { } } } -#endif diff --git a/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift b/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift index fd15fa45..7ad9ad10 100644 --- a/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift +++ b/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) import DequeModule import NIOConcurrencyHelpers @@ -1059,4 +1058,3 @@ extension NIOThrowingAsyncSequenceProducer { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @available(*, unavailable) extension NIOThrowingAsyncSequenceProducer.AsyncIterator: Sendable {} -#endif diff --git a/Sources/NIOCore/ByteBuffer-core.swift b/Sources/NIOCore/ByteBuffer-core.swift index d118bcc3..b60b501b 100644 --- a/Sources/NIOCore/ByteBuffer-core.swift +++ b/Sources/NIOCore/ByteBuffer-core.swift @@ -1068,9 +1068,7 @@ extension ByteBuffer: Hashable { } } -#if swift(>=5.5) && canImport(_Concurrency) extension ByteBuffer: @unchecked Sendable {} -#endif extension ByteBuffer { /// Modify this `ByteBuffer` if this `ByteBuffer` is known to uniquely own its storage. diff --git a/Sources/NIOCore/ConvenienceOptionSupport.swift b/Sources/NIOCore/ConvenienceOptionSupport.swift index a4746ab2..c1017d3b 100644 --- a/Sources/NIOCore/ConvenienceOptionSupport.swift +++ b/Sources/NIOCore/ConvenienceOptionSupport.swift @@ -53,9 +53,7 @@ extension ChannelOptions.Types { } } -#if swift(>=5.5) && canImport(_Concurrency) extension ChannelOptions.Types.ConvenienceOptionValue: Sendable where ValueType: Sendable {} -#endif extension ChannelOptions.Types.ConvenienceOptionValue where ValueType == () { /// Convenience method working with bool options as bool values for set. diff --git a/Sources/NIOCore/EventLoopFuture.swift b/Sources/NIOCore/EventLoopFuture.swift index 52691d2a..564dfaf9 100644 --- a/Sources/NIOCore/EventLoopFuture.swift +++ b/Sources/NIOCore/EventLoopFuture.swift @@ -2186,11 +2186,7 @@ public struct _NIOEventLoopFutureIdentifier: Hashable, NIOSendable { // EventLoopPromise is a reference type, but by its very nature is Sendable. extension EventLoopPromise: NIOSendable { } -#if swift(>=5.5) && canImport(_Concurrency) - // EventLoopFuture is a reference type, but it is Sendable. However, we enforce // that by way of the guarantees of the EventLoop protocol, so the compiler cannot // check it. extension EventLoopFuture: @unchecked NIOSendable { } - -#endif diff --git a/Sources/NIOCore/Interfaces.swift b/Sources/NIOCore/Interfaces.swift index 3ba93a98..9613841b 100644 --- a/Sources/NIOCore/Interfaces.swift +++ b/Sources/NIOCore/Interfaces.swift @@ -348,9 +348,7 @@ public struct NIONetworkDevice { } } -#if swift(>=5.5) && canImport(_Concurrency) extension NIONetworkDevice: @unchecked Sendable {} -#endif extension NIONetworkDevice { fileprivate final class Backing { diff --git a/Sources/NIOCore/NIOSendable.swift b/Sources/NIOCore/NIOSendable.swift index 4a6e96f2..604fae45 100644 --- a/Sources/NIOCore/NIOSendable.swift +++ b/Sources/NIOCore/NIOSendable.swift @@ -38,9 +38,7 @@ struct UnsafeTransfer { } } -#if swift(>=5.5) && canImport(_Concurrency) extension UnsafeTransfer: @unchecked Sendable {} -#endif extension UnsafeTransfer: Equatable where Wrapped: Equatable {} extension UnsafeTransfer: Hashable where Wrapped: Hashable {} @@ -58,6 +56,6 @@ final class UnsafeMutableTransferBox { self.wrappedValue = wrappedValue } } -#if swift(>=5.5) && canImport(_Concurrency) + extension UnsafeMutableTransferBox: @unchecked Sendable {} -#endif + diff --git a/Sources/NIOCore/SocketAddresses.swift b/Sources/NIOCore/SocketAddresses.swift index f5744aa6..0cd62ee2 100644 --- a/Sources/NIOCore/SocketAddresses.swift +++ b/Sources/NIOCore/SocketAddresses.swift @@ -560,15 +560,8 @@ extension SocketAddress: Equatable { } } -#if compiler(>=5.5.2) extension SocketAddress.IPv4Address: Sendable {} extension SocketAddress.IPv6Address: Sendable {} -#elseif compiler(>=5.5) -// Implicit conformance of tuples to Sendable interacts poorly with conditional conformance of Sendable in Swift <=5.5.1 -// https://github.com/apple/swift/issues/57346 -extension SocketAddress.IPv4Address: @unchecked Sendable {} -extension SocketAddress.IPv6Address: @unchecked Sendable {} -#endif /// We define an extension on `SocketAddress` that gives it an elementwise hashable conformance, using /// only the elements defined on the structure in their man pages (excluding lengths). diff --git a/Sources/NIOEmbedded/AsyncTestingChannel.swift b/Sources/NIOEmbedded/AsyncTestingChannel.swift index 3e111a32..81470e82 100644 --- a/Sources/NIOEmbedded/AsyncTestingChannel.swift +++ b/Sources/NIOEmbedded/AsyncTestingChannel.swift @@ -11,7 +11,7 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) + import NIOConcurrencyHelpers import NIOCore @@ -563,5 +563,3 @@ extension NIOAsyncTestingChannel.LeftOverState: @unchecked Sendable { } @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension NIOAsyncTestingChannel.BufferState: @unchecked Sendable { } - -#endif diff --git a/Sources/NIOEmbedded/AsyncTestingEventLoop.swift b/Sources/NIOEmbedded/AsyncTestingEventLoop.swift index b0620e9e..745059c9 100644 --- a/Sources/NIOEmbedded/AsyncTestingEventLoop.swift +++ b/Sources/NIOEmbedded/AsyncTestingEventLoop.swift @@ -11,7 +11,7 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) + import Atomics import Dispatch import _NIODataStructures @@ -375,5 +375,3 @@ private class PromiseCreationStore { precondition(self.promiseCreationStore.isEmpty, "NIOAsyncTestingEventLoop freed with uncompleted promises!") } } - -#endif diff --git a/Sources/NIOHTTP1/HTTPServerUpgradeHandler.swift b/Sources/NIOHTTP1/HTTPServerUpgradeHandler.swift index 8fc19903..4c391933 100644 --- a/Sources/NIOHTTP1/HTTPServerUpgradeHandler.swift +++ b/Sources/NIOHTTP1/HTTPServerUpgradeHandler.swift @@ -325,9 +325,7 @@ public final class HTTPServerUpgradeHandler: ChannelInboundHandler, RemovableCha } } -#if swift(>=5.5) && canImport(_Concurrency) extension HTTPServerUpgradeHandler: @unchecked Sendable {} -#endif extension HTTPServerUpgradeHandler { /// The state of the upgrade handler. diff --git a/Sources/NIOHTTP1/HTTPTypes.swift b/Sources/NIOHTTP1/HTTPTypes.swift index b49eaf0b..219b32e5 100644 --- a/Sources/NIOHTTP1/HTTPTypes.swift +++ b/Sources/NIOHTTP1/HTTPTypes.swift @@ -123,9 +123,7 @@ public struct HTTPRequestHead: Equatable { } } -#if swift(>=5.5) && canImport(_Concurrency) extension HTTPRequestHead: @unchecked Sendable {} -#endif /// The parts of a complete HTTP message, either request or response. /// @@ -139,9 +137,7 @@ public enum HTTPPart { case end(HTTPHeaders?) } -#if swift(>=5.5) && canImport(_Concurrency) extension HTTPPart: Sendable where HeadT: Sendable, BodyT: Sendable {} -#endif extension HTTPPart: Equatable {} @@ -236,9 +232,7 @@ public struct HTTPResponseHead: Equatable { } } -#if swift(>=5.5) && canImport(_Concurrency) extension HTTPResponseHead: @unchecked Sendable {} -#endif extension HTTPResponseHead { /// Determines if the head is purely informational. If a head is informational another head will follow this @@ -497,13 +491,7 @@ public struct HTTPHeaders: CustomStringConvertible, ExpressibleByDictionaryLiter } } -#if compiler(>=5.5.2) extension HTTPHeaders: Sendable {} -#elseif compiler(>=5.5) -// Implicit conformance of tuples to Sendable interacts poorly with conditional conformance of Sendable in Swift <=5.5.1 -// https://github.com/apple/swift/issues/57346 -extension HTTPHeaders: @unchecked Sendable {} -#endif extension HTTPHeaders { diff --git a/Sources/NIOHTTP1/NIOHTTPClientUpgradeHandler.swift b/Sources/NIOHTTP1/NIOHTTPClientUpgradeHandler.swift index 6ea0daf9..14ec0cf5 100644 --- a/Sources/NIOHTTP1/NIOHTTPClientUpgradeHandler.swift +++ b/Sources/NIOHTTP1/NIOHTTPClientUpgradeHandler.swift @@ -378,9 +378,7 @@ public final class NIOHTTPClientUpgradeHandler: ChannelDuplexHandler, RemovableC } } -#if swift(>=5.5) && canImport(_Concurrency) extension NIOHTTPClientUpgradeHandler: @unchecked Sendable {} -#endif extension NIOHTTPClientUpgradeHandler { /// The state of the upgrade handler. diff --git a/Sources/NIOPerformanceTester/Benchmark.swift b/Sources/NIOPerformanceTester/Benchmark.swift index e075e103..f17a35e6 100644 --- a/Sources/NIOPerformanceTester/Benchmark.swift +++ b/Sources/NIOPerformanceTester/Benchmark.swift @@ -30,7 +30,6 @@ func measureAndPrint(desc: String, benchmark bench: B) throws { } } -#if compiler(>=5.5.2) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) protocol AsyncBenchmark: AnyObject, Sendable { func setUp() async throws @@ -57,4 +56,3 @@ func measureAndPrint(desc: String, benchmark bench: B) throws group.wait() } -#endif diff --git a/Sources/NIOPerformanceTester/NIOAsyncWriterSingleWritesBenchmark.swift b/Sources/NIOPerformanceTester/NIOAsyncWriterSingleWritesBenchmark.swift index 39b70e07..5ab0c3fe 100644 --- a/Sources/NIOPerformanceTester/NIOAsyncWriterSingleWritesBenchmark.swift +++ b/Sources/NIOPerformanceTester/NIOAsyncWriterSingleWritesBenchmark.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) import NIOCore import DequeModule import Atomics @@ -54,4 +53,3 @@ final class NIOAsyncWriterSingleWritesBenchmark: AsyncBenchmark, @unchecked Send return self.delegate.counter.load(ordering: .sequentiallyConsistent) } } -#endif diff --git a/Sources/NIOPerformanceTester/main.swift b/Sources/NIOPerformanceTester/main.swift index 07b0f95a..d404f17f 100644 --- a/Sources/NIOPerformanceTester/main.swift +++ b/Sources/NIOPerformanceTester/main.swift @@ -62,7 +62,6 @@ public func measureAndPrint(desc: String, fn: () throws -> Int) rethrows -> Void } } -#if compiler(>=5.5.2) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func measure(_ fn: () async throws -> Int) async rethrows -> [Double] { func measureOne(_ fn: () async throws -> Int) async rethrows -> Double { @@ -91,7 +90,6 @@ public func measureAndPrint(desc: String, fn: () async throws -> Int) async reth print("skipping '\(desc)', limit set = \(limitSet)") } } -#endif // MARK: Utilities @@ -1085,7 +1083,6 @@ try measureAndPrint( ) ) -#if compiler(>=5.5.2) && canImport(_Concurrency) if #available(macOS 10.15, *) { try measureAndPrint( desc: "asyncwriter_single_writes_1M_times", @@ -1094,4 +1091,3 @@ if #available(macOS 10.15, *) { ) ) } -#endif diff --git a/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift b/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift index f2ded61c..d904ae31 100644 --- a/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift +++ b/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift @@ -358,9 +358,7 @@ public final class MultiThreadedEventLoopGroup: EventLoopGroup { } } -#if swift(>=5.5) && canImport(_Concurrency) extension MultiThreadedEventLoopGroup: @unchecked Sendable {} -#endif extension MultiThreadedEventLoopGroup: CustomStringConvertible { public var description: String { diff --git a/Sources/NIOPosix/NIOThreadPool.swift b/Sources/NIOPosix/NIOThreadPool.swift index 8a69b71f..eeda5835 100644 --- a/Sources/NIOPosix/NIOThreadPool.swift +++ b/Sources/NIOPosix/NIOThreadPool.swift @@ -252,9 +252,7 @@ public final class NIOThreadPool { } } -#if swift(>=5.5) && canImport(_Concurrency) extension NIOThreadPool: @unchecked Sendable {} -#endif extension NIOThreadPool { diff --git a/Sources/NIOPosix/Thread.swift b/Sources/NIOPosix/Thread.swift index 23bcbcfc..be392dec 100644 --- a/Sources/NIOPosix/Thread.swift +++ b/Sources/NIOPosix/Thread.swift @@ -228,9 +228,7 @@ public final class ThreadSpecificVariable { } } -#if swift(>=5.5) && canImport(_Concurrency) extension ThreadSpecificVariable: @unchecked Sendable where Value: Sendable {} -#endif extension NIOThread: Equatable { static func ==(lhs: NIOThread, rhs: NIOThread) -> Bool { diff --git a/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift b/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift index 1d074aae..f84b570c 100644 --- a/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift +++ b/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift @@ -209,7 +209,6 @@ extension ByteToMessageDecoderVerifier { } } -#if swift(>=5.5) && canImport(_Concurrency) /// `VerificationError` conforms to `Error` and therefore needs to conform to `Sendable` too. /// `VerificationError` has a stored property `errorCode` of type `ErrorCode` which can store `NIOAny` which is not and can not be `Sendable`. /// In addtion, `ErrorCode` can also store a user defined `OutputType` which is not required to be `Sendable` but we could require it to be `Sendable`. @@ -220,4 +219,3 @@ extension ByteToMessageDecoderVerifier { /// it sound like the best option to just stick to the conformances we already have and **not** lie twice by making `VerificationError` conform to `Sendable` too. /// Note that this still allows us to adopt `Sendable` for `ErrorCode` later if we change our opinion. extension ByteToMessageDecoderVerifier.VerificationError: @unchecked Sendable {} -#endif diff --git a/Sources/NIOTestUtils/NIOHTTP1TestServer.swift b/Sources/NIOTestUtils/NIOHTTP1TestServer.swift index 1b449c61..14a91bd0 100644 --- a/Sources/NIOTestUtils/NIOHTTP1TestServer.swift +++ b/Sources/NIOTestUtils/NIOHTTP1TestServer.swift @@ -46,9 +46,7 @@ private final class BlockingQueue { } } -#if swift(>=5.5) && canImport(_Concurrency) extension BlockingQueue: @unchecked Sendable where Element: Sendable {} -#endif private final class WebServerHandler: ChannelDuplexHandler { diff --git a/Sources/NIOWebSocket/WebSocketFrame.swift b/Sources/NIOWebSocket/WebSocketFrame.swift index c6c68c82..4ced53ef 100644 --- a/Sources/NIOWebSocket/WebSocketFrame.swift +++ b/Sources/NIOWebSocket/WebSocketFrame.swift @@ -323,9 +323,7 @@ public struct WebSocketFrame { } } -#if swift(>=5.5) && canImport(_Concurrency) extension WebSocketFrame: @unchecked Sendable {} -#endif extension WebSocketFrame: Equatable {} diff --git a/Sources/_NIODataStructures/Heap.swift b/Sources/_NIODataStructures/Heap.swift index 983c1931..15c0a6c0 100644 --- a/Sources/_NIODataStructures/Heap.swift +++ b/Sources/_NIODataStructures/Heap.swift @@ -264,9 +264,5 @@ extension Heap: Sequence { } } -#if swift(>=5.5) && canImport(_Concurrency) - extension Heap: Sendable where Element: Sendable {} extension HeapIterator: Sendable where Element: Sendable {} - -#endif diff --git a/Sources/_NIODataStructures/PriorityQueue.swift b/Sources/_NIODataStructures/PriorityQueue.swift index e4e2ecf9..b04b50f6 100644 --- a/Sources/_NIODataStructures/PriorityQueue.swift +++ b/Sources/_NIODataStructures/PriorityQueue.swift @@ -102,9 +102,5 @@ extension PriorityQueue: CustomStringConvertible { } } -#if swift(>=5.5) && canImport(_Concurrency) - extension PriorityQueue: Sendable where Element: Sendable {} extension PriorityQueue.Iterator: Sendable where Element: Sendable {} - -#endif diff --git a/Tests/NIOCoreTests/AsyncSequenceTests.swift b/Tests/NIOCoreTests/AsyncSequenceTests.swift index b7658b33..4f563ed3 100644 --- a/Tests/NIOCoreTests/AsyncSequenceTests.swift +++ b/Tests/NIOCoreTests/AsyncSequenceTests.swift @@ -27,7 +27,6 @@ fileprivate struct TestCase { final class AsyncSequenceCollectTests: XCTestCase { func testAsyncSequenceCollect() { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest(timeout: 5) { let testCases = [ @@ -159,12 +158,9 @@ final class AsyncSequenceCollectTests: XCTestCase { } } } - #endif } } -#if compiler(>=5.5.2) && canImport(_Concurrency) - @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) struct AsyncSequenceFromSyncSequence: AsyncSequence { typealias Element = Wrapped.Element @@ -189,5 +185,3 @@ extension Sequence { .init(wrapped: self) } } - -#endif diff --git a/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceProducer+HighLowWatermarkBackPressureStrategyTests.swift b/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceProducer+HighLowWatermarkBackPressureStrategyTests.swift index c2127bc7..564954da 100644 --- a/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceProducer+HighLowWatermarkBackPressureStrategyTests.swift +++ b/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceProducer+HighLowWatermarkBackPressureStrategyTests.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) import NIOCore import XCTest @@ -58,4 +57,3 @@ final class NIOAsyncSequenceProducerBackPressureStrategiesHighLowWatermarkTests: XCTAssertFalse(self.strategy.didConsume(bufferDepth: 5)) } } -#endif diff --git a/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceTests.swift b/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceTests.swift index 37b9e98c..64f405af 100644 --- a/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceTests.swift +++ b/Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceTests.swift @@ -15,7 +15,6 @@ import NIOCore import XCTest -#if compiler(>=5.5.2) && canImport(_Concurrency) final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBackPressureStrategy, @unchecked Sendable { var didYieldCallCount = 0 var didYieldHandler: ((Int) -> Bool)? @@ -622,5 +621,3 @@ fileprivate func XCTAssertEqualWithoutAutoclosure( let result = expression1 == expression2 XCTAssertTrue(result, message(), file: file, line: line) } - -#endif diff --git a/Tests/NIOCoreTests/AsyncSequences/NIOAsyncWriterTests.swift b/Tests/NIOCoreTests/AsyncSequences/NIOAsyncWriterTests.swift index 2198b100..b3bb8e2c 100644 --- a/Tests/NIOCoreTests/AsyncSequences/NIOAsyncWriterTests.swift +++ b/Tests/NIOCoreTests/AsyncSequences/NIOAsyncWriterTests.swift @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5.2) && canImport(_Concurrency) import DequeModule import NIOCore import XCTest @@ -529,4 +528,3 @@ final class NIOAsyncWriterTests: XCTestCase { XCTAssertEqual(self.delegate.didTerminateCallCount, 1) } } -#endif diff --git a/Tests/NIOCoreTests/AsyncSequences/NIOThrowingAsyncSequenceTests.swift b/Tests/NIOCoreTests/AsyncSequences/NIOThrowingAsyncSequenceTests.swift index c6c6d5e4..4731667f 100644 --- a/Tests/NIOCoreTests/AsyncSequences/NIOThrowingAsyncSequenceTests.swift +++ b/Tests/NIOCoreTests/AsyncSequences/NIOThrowingAsyncSequenceTests.swift @@ -15,7 +15,6 @@ import NIOCore import XCTest -#if compiler(>=5.5.2) && canImport(_Concurrency) final class NIOThrowingAsyncSequenceProducerTests: XCTestCase { private var backPressureStrategy: MockNIOElementStreamBackPressureStrategy! private var delegate: MockNIOBackPressuredStreamSourceDelegate! @@ -726,5 +725,3 @@ fileprivate func XCTAssertEqualWithoutAutoclosure( let result = expression1 == expression2 XCTAssertTrue(result, message(), file: file, line: line) } - -#endif diff --git a/Tests/NIOCoreTests/XCTest+AsyncAwait.swift b/Tests/NIOCoreTests/XCTest+AsyncAwait.swift index 6e290989..11a8db2c 100644 --- a/Tests/NIOCoreTests/XCTest+AsyncAwait.swift +++ b/Tests/NIOCoreTests/XCTest+AsyncAwait.swift @@ -39,7 +39,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.5.2) && canImport(_Concurrency) + import XCTest extension XCTestCase { @@ -116,4 +116,3 @@ internal func XCTAssertNoThrowWithResult( return nil } -#endif diff --git a/Tests/NIOEmbeddedTests/AsyncTestingChannelTests.swift b/Tests/NIOEmbeddedTests/AsyncTestingChannelTests.swift index acd8a499..b806fc27 100644 --- a/Tests/NIOEmbeddedTests/AsyncTestingChannelTests.swift +++ b/Tests/NIOEmbeddedTests/AsyncTestingChannelTests.swift @@ -19,7 +19,6 @@ import NIOCore class AsyncTestingChannelTests: XCTestCase { func testSingleHandlerInit() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { class Handler: ChannelInboundHandler { @@ -29,13 +28,9 @@ class AsyncTestingChannelTests: XCTestCase { let channel = await NIOAsyncTestingChannel(handler: Handler()) XCTAssertNoThrow(try channel.pipeline.handler(type: Handler.self).wait()) } - #else - throw XCTSkip() - #endif } func testEmptyInit() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } class Handler: ChannelInboundHandler { @@ -47,13 +42,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertEqual(e as? ChannelPipelineError, .notFound) } - #else - throw XCTSkip() - #endif } func testMultipleHandlerInit() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { class Handler: ChannelInboundHandler, RemovableChannelHandler { @@ -77,13 +68,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertNoThrow(XCTAssertEqual(try channel.pipeline.handler(type: Handler.self).wait().identifier, "2")) XCTAssertNoThrow(try channel.pipeline.removeHandler(name: "handler2").wait()) } - #else - throw XCTSkip() - #endif } func testWriteOutboundByteBuffer() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -104,13 +91,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertNoThrow(XCTAssertNil(nextOutboundRead)) XCTAssertNoThrow(XCTAssertNil(nextInboundRead)) } - #else - throw XCTSkip() - #endif } func testWriteOutboundByteBufferMultipleTimes() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -131,13 +114,9 @@ class AsyncTestingChannelTests: XCTestCase { try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self)) try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self)) } - #else - throw XCTSkip() - #endif } func testWriteInboundByteBuffer() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -150,13 +129,9 @@ class AsyncTestingChannelTests: XCTestCase { try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self)) try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self)) } - #else - throw XCTSkip() - #endif } func testWriteInboundByteBufferMultipleTimes() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -177,13 +152,9 @@ class AsyncTestingChannelTests: XCTestCase { try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self)) try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self)) } - #else - throw XCTSkip() - #endif } func testWriteInboundByteBufferReThrow() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -193,13 +164,9 @@ class AsyncTestingChannelTests: XCTestCase { } try await XCTAsyncAssertTrue(await channel.finish().isClean) } - #else - throw XCTSkip() - #endif } func testWriteOutboundByteBufferReThrow() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -209,13 +176,9 @@ class AsyncTestingChannelTests: XCTestCase { } try await XCTAsyncAssertTrue(await channel.finish().isClean) } - #else - throw XCTSkip() - #endif } func testReadOutboundWrongTypeThrows() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -230,13 +193,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTFail() } } - #else - throw XCTSkip() - #endif } func testReadInboundWrongTypeThrows() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -251,13 +210,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTFail() } } - #else - throw XCTSkip() - #endif } func testWrongTypesWithFastpathTypes() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -306,13 +261,9 @@ class AsyncTestingChannelTests: XCTestCase { await check(expected: ByteBuffer.self, actual: AddressedEnvelope.self) await check(expected: AddressedEnvelope.self, actual: IOData.self) } - #else - throw XCTSkip() - #endif } func testCloseMultipleTimesThrows() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -326,13 +277,9 @@ class AsyncTestingChannelTests: XCTestCase { // Nothing to do here. } } - #else - throw XCTSkip() - #endif } func testCloseOnInactiveIsOk() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -343,13 +290,9 @@ class AsyncTestingChannelTests: XCTestCase { // channelInactive should fire only once. XCTAssertEqual(inactiveHandler.inactiveNotifications, 1) } - #else - throw XCTSkip() - #endif } func testEmbeddedLifecycle() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let handler = ChannelLifecycleHandler() @@ -368,9 +311,6 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertEqual(handler.currentState, .unregistered) XCTAssertFalse(channel.isActive) } - #else - throw XCTSkip() - #endif } private final class ExceptionThrowingInboundHandler : ChannelInboundHandler { @@ -401,7 +341,6 @@ class AsyncTestingChannelTests: XCTestCase { } func testEmbeddedChannelAndPipelineAndChannelCoreShareTheEventLoop() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -410,13 +349,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssert(pipelineEventLoop === (channel._channelCore as! EmbeddedChannelCore).eventLoop) try await XCTAsyncAssertTrue(await channel.finish().isClean) } - #else - throw XCTSkip() - #endif } func testSendingAnythingOnEmbeddedChannel() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -435,13 +370,9 @@ class AsyncTestingChannelTests: XCTestCase { try await channel.writeAndFlush(IOData.fileRegion(fileRegion)) try await channel.writeAndFlush(AddressedEnvelope(remoteAddress: socketAddress, data: buffer)) } - #else - throw XCTSkip() - #endif } func testActiveWhenConnectPromiseFiresAndInactiveWhenClosePromiseFires() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -461,13 +392,9 @@ class AsyncTestingChannelTests: XCTestCase { channel.close(promise: closePromise) try await closePromise.futureResult.get() } - #else - throw XCTSkip() - #endif } func testWriteWithoutFlushDoesNotWrite() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -481,13 +408,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertTrue(writeFuture.isFulfilled) try await XCTAsyncAssertTrue(await channel.finish().isClean) } - #else - throw XCTSkip() - #endif } func testSetLocalAddressAfterSuccessfulBind() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } let channel = NIOAsyncTestingChannel() @@ -499,13 +422,9 @@ class AsyncTestingChannelTests: XCTestCase { } try bindPromise.futureResult.wait() - #else - throw XCTSkip() - #endif } func testSetRemoteAddressAfterSuccessfulConnect() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } let channel = NIOAsyncTestingChannel() @@ -517,13 +436,9 @@ class AsyncTestingChannelTests: XCTestCase { } try connectPromise.futureResult.wait() - #else - throw XCTSkip() - #endif } func testUnprocessedOutboundUserEventFailsOnEmbeddedChannel() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } let channel = NIOAsyncTestingChannel() @@ -535,13 +450,9 @@ class AsyncTestingChannelTests: XCTestCase { } } - #else - throw XCTSkip() - #endif } func testEmbeddedChannelWritabilityIsWritable() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } let channel = NIOAsyncTestingChannel() @@ -552,13 +463,9 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertFalse(channel.isWritable) XCTAssertFalse(opaqueChannel.isWritable) - #else - throw XCTSkip() - #endif } func testFinishWithRecursivelyScheduledTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() @@ -576,13 +483,9 @@ class AsyncTestingChannelTests: XCTestCase { _ = try await channel.finish() XCTAssertEqual(invocations.load(), 1) } - #else - throw XCTSkip() - #endif } func testSyncOptionsAreSupported() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } let channel = NIOAsyncTestingChannel() try channel.testingEventLoop.submit { @@ -592,26 +495,18 @@ class AsyncTestingChannelTests: XCTestCase { XCTAssertEqual(try options?.getOption(ChannelOptions.autoRead), true) // (Setting options isn't supported.) }.wait() - #else - throw XCTSkip() - #endif } func testSecondFinishThrows() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let channel = NIOAsyncTestingChannel() _ = try await channel.finish() await XCTAsyncAssertThrowsError(try await channel.finish()) } - #else - throw XCTSkip() - #endif } } -#if compiler(>=5.5.2) && canImport(_Concurrency) fileprivate func XCTAsyncAssertTrue(_ predicate: @autoclosure () async throws -> Bool, file: StaticString = #file, line: UInt = #line) async rethrows { let result = try await predicate() XCTAssertTrue(result, file: file, line: line) @@ -656,4 +551,3 @@ final class AtomicCounter: @unchecked Sendable { self.baseCounter.load(ordering: .relaxed) } } -#endif diff --git a/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift b/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift index f3076374..d4391647 100644 --- a/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift +++ b/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift @@ -25,7 +25,6 @@ private class EmbeddedTestError: Error { } final class NIOAsyncTestingEventLoopTests: XCTestCase { func testExecuteDoesNotImmediatelyRunTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackRan = ManagedAtomic(false) @@ -37,13 +36,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await loop.run() XCTAssertTrue(callbackRan.load(ordering: .relaxed)) } - #else - throw XCTSkip() - #endif } func testExecuteWillRunAllTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let runCount = ManagedAtomic(0) @@ -60,13 +55,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(runCount.load(ordering: .relaxed), 3) } } - #else - throw XCTSkip() - #endif } func testExecuteWillRunTasksAddedRecursively() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let sentinel = ManagedAtomic(0) @@ -96,13 +87,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(sentinel.load(ordering: .relaxed), 3) } } - #else - throw XCTSkip() - #endif } func testExecuteRunsImmediately() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackRan = ManagedAtomic(false) @@ -121,13 +108,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertFalse(callbackRan.load(ordering: .relaxed)) } } - #else - throw XCTSkip() - #endif } func testTasksScheduledAfterRunDontRun() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackRan = ManagedAtomic(false) @@ -148,13 +131,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertFalse(callbackRan.load(ordering: .relaxed)) } } - #else - throw XCTSkip() - #endif } func testSubmitRunsImmediately() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackRan = ManagedAtomic(false) @@ -173,13 +152,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertFalse(callbackRan.load(ordering: .relaxed)) } } - #else - throw XCTSkip() - #endif } func testSyncShutdownGracefullyRunsTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackRan = ManagedAtomic(false) @@ -194,13 +169,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertTrue(callbackRan.load(ordering: .relaxed)) } } - #else - throw XCTSkip() - #endif } func testShutdownGracefullyRunsTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackRan = ManagedAtomic(false) @@ -215,13 +186,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertTrue(callbackRan.load(ordering: .relaxed)) } } - #else - throw XCTSkip() - #endif } func testCanControlTime() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let callbackCount = ManagedAtomic(0) @@ -250,13 +217,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(callbackCount.load(ordering: .relaxed), 1) } } - #else - throw XCTSkip() - #endif } func testCanScheduleMultipleTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let sentinel = ManagedAtomic(0) @@ -277,13 +240,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { } } } - #else - throw XCTSkip() - #endif } func testExecutedTasksFromScheduledOnesAreRun() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let sentinel = ManagedAtomic(0) @@ -304,13 +263,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(sentinel.load(ordering: .relaxed), 2) } } - #else - throw XCTSkip() - #endif } func testScheduledTasksFromScheduledTasksProperlySchedule() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let sentinel = ManagedAtomic(0) @@ -350,13 +305,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(sentinel.load(ordering: .relaxed), 3) } } - #else - throw XCTSkip() - #endif } func testScheduledTasksFromExecutedTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let sentinel = ManagedAtomic(0) @@ -375,13 +326,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(sentinel.load(ordering: .relaxed), 2) } } - #else - throw XCTSkip() - #endif } func testCancellingScheduledTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let loop = NIOAsyncTestingEventLoop() @@ -392,13 +339,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await loop.advanceTime(by: .nanoseconds(20)) } - #else - throw XCTSkip() - #endif } func testScheduledTasksFuturesFire() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let fired = ManagedAtomic(false) @@ -411,13 +354,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await loop.advanceTime(by: .nanoseconds(1)) XCTAssertTrue(fired.load(ordering: .relaxed)) } - #else - throw XCTSkip() - #endif } func testScheduledTasksFuturesError() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let err = EmbeddedTestError() @@ -439,13 +378,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await loop.advanceTime(by: .nanoseconds(1)) XCTAssertTrue(fired.load(ordering: .relaxed)) } - #else - throw XCTSkip() - #endif } func testTaskOrdering() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { // This test validates that the ordering of task firing on NIOAsyncTestingEventLoop via @@ -526,13 +461,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { // Now the final value should be 6. XCTAssertEqual(orderingCounter.load(ordering: .relaxed), 6) } - #else - throw XCTSkip() - #endif } func testCancelledScheduledTasksDoNotHoldOnToRunClosure() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -559,13 +490,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { XCTAssertEqual(EventLoopError.cancelled, error as? EventLoopError) } } - #else - throw XCTSkip() - #endif } func testDrainScheduledTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -585,13 +512,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await eventLoop.shutdownGracefully() XCTAssertEqual(tasksRun.load(ordering: .relaxed), 2) } - #else - throw XCTSkip() - #endif } func testDrainScheduledTasksDoesNotRunNewlyScheduledTasks() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -608,13 +531,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await eventLoop.shutdownGracefully() XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1) } - #else - throw XCTSkip() - #endif } func testAdvanceTimeToDeadline() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -628,13 +547,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await eventLoop.advanceTime(to: deadline) XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1) } - #else - throw XCTSkip() - #endif } func testWeCantTimeTravelByAdvancingTimeToThePast() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -656,13 +571,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await eventLoop.advanceTime(by: .seconds(2)) XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1) } - #else - throw XCTSkip() - #endif } func testExecuteInOrder() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -686,13 +597,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await eventLoop.run() XCTAssertEqual(counter.load(ordering: .relaxed), 3) } - #else - throw XCTSkip() - #endif } func testScheduledTasksInOrder() throws { - #if compiler(>=5.5.2) && canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() } XCTAsyncTest { let eventLoop = NIOAsyncTestingEventLoop() @@ -716,8 +623,5 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { await eventLoop.advanceTime(by: .seconds(1)) XCTAssertEqual(counter.load(ordering: .relaxed), 3) } - #else - throw XCTSkip() - #endif } } diff --git a/Tests/NIOEmbeddedTests/XCTest+AsyncAwait.swift b/Tests/NIOEmbeddedTests/XCTest+AsyncAwait.swift index f3fb94f7..9b92788f 100644 --- a/Tests/NIOEmbeddedTests/XCTest+AsyncAwait.swift +++ b/Tests/NIOEmbeddedTests/XCTest+AsyncAwait.swift @@ -39,7 +39,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.5.2) && canImport(_Concurrency) + import XCTest extension XCTestCase { @@ -102,5 +102,3 @@ internal func XCTAssertNoThrowWithResult( } return nil } - -#endif diff --git a/Tests/NIOHTTP1Tests/UnsafeTransfer.swift b/Tests/NIOHTTP1Tests/UnsafeTransfer.swift index 5070296e..007d96bd 100644 --- a/Tests/NIOHTTP1Tests/UnsafeTransfer.swift +++ b/Tests/NIOHTTP1Tests/UnsafeTransfer.swift @@ -26,9 +26,7 @@ struct UnsafeTransfer { } } -#if swift(>=5.5) && canImport(_Concurrency) extension UnsafeTransfer: @unchecked Sendable {} -#endif extension UnsafeTransfer: Equatable where Wrapped: Equatable {} extension UnsafeTransfer: Hashable where Wrapped: Hashable {} @@ -46,6 +44,5 @@ final class UnsafeMutableTransferBox { self.wrappedValue = wrappedValue } } -#if swift(>=5.5) && canImport(_Concurrency) + extension UnsafeMutableTransferBox: @unchecked Sendable {} -#endif