Skip to content

Commit

Permalink
Remove #if compiler(>=5.5) (#2292)
Browse files Browse the repository at this point in the history
### Motivation
We only support Swift 5.5.2+.

### Modification
Remove all `#if swift(>=5.5)` conditional compilation blocks.

### Result
less branching
  • Loading branch information
dnadoba committed Oct 13, 2022
1 parent 788b759 commit c7b4989
Show file tree
Hide file tree
Showing 48 changed files with 16 additions and 559 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -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] <br> SwiftNIO core | `from: "2.0.0"`
[https://github.com/apple/swift-nio-ssl][repo-nio-ssl] <br> TLS (SSL) support | `from: "2.0.0"`
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Expand Up @@ -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.

Expand Down
2 changes: 0 additions & 2 deletions Sources/NIOAsyncAwaitDemo/AsyncChannelIO.swift
Expand Up @@ -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<Request, Response> {
let channel: Channel
Expand All @@ -39,4 +38,3 @@ struct AsyncChannelIO<Request, Response> {
try await self.channel.close()
}
}
#endif
5 changes: 0 additions & 5 deletions Sources/NIOAsyncAwaitDemo/main.swift
Expand Up @@ -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<HTTPRequestHead, NIOHTTPClientResponseFull> {
let channel = try await ClientBootstrap(group: group).connect(host: host, port: port).get()
Expand Down Expand Up @@ -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
2 changes: 0 additions & 2 deletions Sources/NIOChatServer/main.swift
Expand Up @@ -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!
Expand Down
6 changes: 1 addition & 5 deletions Sources/NIOConcurrencyHelpers/NIOAtomic.swift
Expand Up @@ -313,9 +313,5 @@ public final class NIOAtomic<T: NIOAtomicPrimitive> {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(*, deprecated)
extension NIOAtomic: Sendable {

}
#endif
extension NIOAtomic: Sendable {}
2 changes: 0 additions & 2 deletions Sources/NIOConcurrencyHelpers/NIOLock.swift
Expand Up @@ -147,7 +147,5 @@ extension NIOLock {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
extension NIOLock: Sendable {}
extension NIOLock._Storage: Sendable {}
#endif
2 changes: 0 additions & 2 deletions Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift
Expand Up @@ -52,7 +52,5 @@ public struct NIOLockedValueBox<Value> {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
extension NIOLockedValueBox: Sendable where Value: Sendable {}
extension NIOLockedValueBox._Storage: @unchecked Sendable {}
#endif
10 changes: 2 additions & 8 deletions Sources/NIOConcurrencyHelpers/lock.swift
Expand Up @@ -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 {}
218 changes: 0 additions & 218 deletions Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Sources/NIOCore/AsyncAwaitSupport.swift
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

extension EventLoopFuture {
/// Get the value/error from an `EventLoopFuture` in an `async` context.
///
Expand Down Expand Up @@ -332,5 +330,3 @@ struct AsyncSequenceFromIterator<AsyncIterator: AsyncIteratorProtocol>: AsyncSeq
self.iterator
}
}

#endif
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)
import DequeModule
import NIOConcurrencyHelpers

Expand Down Expand Up @@ -329,4 +328,4 @@ extension NIOAsyncSequenceProducer {
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
@available(*, unavailable)
extension NIOAsyncSequenceProducer.AsyncIterator: Sendable {}
#endif

Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)
public enum NIOAsyncSequenceProducerBackPressureStrategies {
/// A high-low watermarked back-pressure strategy for a ``NIOAsyncSequenceProducer``.
///
Expand Down Expand Up @@ -46,4 +45,3 @@ public enum NIOAsyncSequenceProducerBackPressureStrategies {
}
}
}
#endif
2 changes: 0 additions & 2 deletions Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)
import Atomics
import DequeModule
import NIOConcurrencyHelpers
Expand Down Expand Up @@ -1065,4 +1064,3 @@ extension NIOAsyncWriter {
}
}
}
#endif

0 comments on commit c7b4989

Please sign in to comment.