Skip to content

Commit b2faff9

Browse files
authored
Drop Swift 5.10 (#870)
1 parent b2ae845 commit b2faff9

File tree

8 files changed

+11
-117
lines changed

8 files changed

+11
-117
lines changed

Package.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.10
1+
// swift-tools-version:6.0
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the AsyncHTTPClient open source project
@@ -19,10 +19,6 @@ let strictConcurrencyDevelopment = false
1919

2020
let strictConcurrencySettings: [SwiftSetting] = {
2121
var initialSettings: [SwiftSetting] = []
22-
initialSettings.append(contentsOf: [
23-
.enableUpcomingFeature("StrictConcurrency"),
24-
.enableUpcomingFeature("InferSendableFromCaptures"),
25-
])
2622

2723
if strictConcurrencyDevelopment {
2824
// -warnings-as-errors here is a workaround so that IDE-based development can

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Please have a look at [SECURITY.md](SECURITY.md) for AsyncHTTPClient's security
306306

307307
## Supported Versions
308308

309-
The most recent versions of AsyncHTTPClient support Swift 5.10 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:
309+
The most recent versions of AsyncHTTPClient support Swift 6.0 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:
310310

311311
AsyncHTTPClient | Minimum Swift Version
312312
--------------------|----------------------
@@ -318,4 +318,5 @@ AsyncHTTPClient | Minimum Swift Version
318318
`1.20.0 ..< 1.21.0` | 5.7
319319
`1.21.0 ..< 1.26.0` | 5.8
320320
`1.26.0 ..< 1.27.0` | 5.9
321-
`1.27.0 ...` | 5.10
321+
`1.27.0 ..< 1.30.0` | 5.10
322+
`1.30.0 ...` | 6.0

Sources/AsyncHTTPClient/DeconstructedURL.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extension DeconstructedURL {
4848

4949
switch scheme {
5050
case .http, .https:
51-
#if !canImport(Darwin) && compiler(>=6.0)
51+
#if !canImport(Darwin)
5252
guard let urlHost = url.host, !urlHost.isEmpty else {
5353
throw HTTPClientError.emptyHost
5454
}
@@ -89,7 +89,7 @@ extension DeconstructedURL {
8989
}
9090
}
9191

92-
#if !canImport(Darwin) && compiler(>=6.0)
92+
#if !canImport(Darwin)
9393
extension String {
9494
@inlinable internal func trimIPv6Brackets() -> String {
9595
var utf8View = self.utf8[...]

Sources/AsyncHTTPClient/HTTPClient+StructuredConcurrency.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import NIO
1717

1818
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
1919
extension HTTPClient {
20-
#if compiler(>=6.0)
2120
/// Start & automatically shut down a new ``HTTPClient``.
2221
///
2322
/// This method allows to start & automatically dispose of a ``HTTPClient`` following the principle of Structured Concurrency.
@@ -43,30 +42,4 @@ extension HTTPClient {
4342
try await httpClient.shutdown()
4443
}
4544
}
46-
#else
47-
/// Start & automatically shut down a new ``HTTPClient``.
48-
///
49-
/// This method allows to start & automatically dispose of a ``HTTPClient`` following the principle of Structured Concurrency.
50-
/// The ``HTTPClient`` is guaranteed to be shut down upon return, whether `body` throws or not.
51-
///
52-
/// This may be particularly useful if you cannot use the shared singleton (``HTTPClient/shared``).
53-
public static func withHTTPClient<Return: Sendable>(
54-
eventLoopGroup: any EventLoopGroup = HTTPClient.defaultEventLoopGroup,
55-
configuration: Configuration = Configuration(),
56-
backgroundActivityLogger: Logger? = nil,
57-
_ body: (HTTPClient) async throws -> Return
58-
) async throws -> Return {
59-
let logger = (backgroundActivityLogger ?? HTTPClient.loggingDisabled)
60-
let httpClient = HTTPClient(
61-
eventLoopGroup: eventLoopGroup,
62-
configuration: configuration,
63-
backgroundActivityLogger: logger
64-
)
65-
return try await asyncDo {
66-
try await body(httpClient)
67-
} finally: { _ in
68-
try await httpClient.shutdown()
69-
}
70-
}
71-
#endif
7245
}

Sources/AsyncHTTPClient/HTTPHandler.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Algorithms
16+
import Foundation
1617
import Logging
1718
import NIOConcurrencyHelpers
1819
import NIOCore
@@ -21,12 +22,6 @@ import NIOPosix
2122
import NIOSSL
2223
import Tracing
2324

24-
#if compiler(>=6.0)
25-
import Foundation
26-
#else
27-
@preconcurrency import Foundation
28-
#endif
29-
3025
extension HTTPClient {
3126
/// A request body.
3227
public struct Body: Sendable {

Sources/AsyncHTTPClient/StructuredConcurrencyHelpers.swift

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
// Note: Whitespace changes are used to workaround compiler bug
1616
// https://github.com/swiftlang/swift/issues/79285
1717

18-
#if compiler(>=6.0)
1918
@inlinable
2019
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
2120
internal func asyncDo<R>(
2221
isolation: isolated (any Actor)? = #isolation,
23-
// DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
24-
// https://github.com/swiftlang/swift/issues/79285
25-
_ body: () async throws -> sending R, finally: sending @escaping ((any Error)?) async throws -> Void) async throws -> sending R {
22+
_ body: () async throws -> sending R,
23+
finally: sending @escaping ((any Error)?) async throws -> Void
24+
) async throws -> sending R {
2625
let result: R
2726
do {
2827
result = try await body()
@@ -48,36 +47,3 @@ internal func asyncDo<R>(
4847
}.value
4948
return result
5049
}
51-
#else
52-
@inlinable
53-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
54-
internal func asyncDo<R: Sendable>(
55-
_ body: () async throws -> R,
56-
finally: @escaping @Sendable ((any Error)?) async throws -> Void
57-
) async throws -> R {
58-
let result: R
59-
do {
60-
result = try await body()
61-
} catch {
62-
// `body` failed, we need to invoke `finally` with the `error`.
63-
64-
// This _looks_ unstructured but isn't really because we unconditionally always await the return.
65-
// We need to have an uncancelled task here to assure this is actually running in case we hit a
66-
// cancellation error.
67-
try await Task {
68-
try await finally(error)
69-
}.value
70-
throw error
71-
}
72-
73-
// `body` succeeded, we need to invoke `finally` with `nil` (no error).
74-
75-
// This _looks_ unstructured but isn't really because we unconditionally always await the return.
76-
// We need to have an uncancelled task here to assure this is actually running in case we hit a
77-
// cancellation error.
78-
try await Task {
79-
try await finally(nil)
80-
}.value
81-
return result
82-
}
83-
#endif

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
4646

4747
let request3 = try Request(url: "unix:///tmp/file")
4848
XCTAssertEqual(request3.host, "")
49-
#if os(Linux) && compiler(>=6.0) && compiler(<6.1)
49+
#if os(Linux) && compiler(<6.1)
5050
XCTAssertEqual(request3.url.host, "")
5151
#else
5252
XCTAssertNil(request3.url.host)

Tests/AsyncHTTPClientTests/TransactionTests.swift

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ private actor Promise<Value: Sendable> {
657657

658658
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
659659
extension Transaction {
660-
#if compiler(>=6.0)
661660
fileprivate static func makeWithResultTask(
662661
request: sending PreparedRequest,
663662
requestOptions: RequestOptions = .forTests(),
@@ -685,40 +684,4 @@ extension Transaction {
685684

686685
return (await transactionPromise.value, task)
687686
}
688-
#else
689-
fileprivate static func makeWithResultTask(
690-
request: PreparedRequest,
691-
requestOptions: RequestOptions = .forTests(),
692-
logger: Logger = Logger(label: "test"),
693-
connectionDeadline: NIODeadline = .distantFuture,
694-
preferredEventLoop: EventLoop
695-
) async -> (Transaction, _Concurrency.Task<HTTPClientResponse, Error>) {
696-
// It isn't sendable ... but on 6.0 and later we use 'sending'.
697-
struct UnsafePrepareRequest: @unchecked Sendable {
698-
var value: PreparedRequest
699-
}
700-
701-
let transactionPromise = Promise<Transaction>()
702-
let unsafe = UnsafePrepareRequest(value: request)
703-
let task = Task {
704-
try await withCheckedThrowingContinuation {
705-
(continuation: CheckedContinuation<HTTPClientResponse, Error>) in
706-
let request = unsafe.value
707-
let transaction = Transaction(
708-
request: request,
709-
requestOptions: requestOptions,
710-
logger: logger,
711-
connectionDeadline: connectionDeadline,
712-
preferredEventLoop: preferredEventLoop,
713-
responseContinuation: continuation
714-
)
715-
Task {
716-
await transactionPromise.fulfil(transaction)
717-
}
718-
}
719-
}
720-
721-
return (await transactionPromise.value, task)
722-
}
723-
#endif
724687
}

0 commit comments

Comments
 (0)