Skip to content

Commit 748978f

Browse files
authored
Remove outdated compiler conditionals (#6253)
SwiftPM now requires 5.7 tools as a minimum, so we can drop any conditionals needed for building with older compilers.
1 parent 18e422c commit 748978f

23 files changed

+1
-107
lines changed

Sources/Basics/Concurrency/ConcurrencyHelpers.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ extension DispatchQueue {
4646
)
4747
}
4848

49-
#if swift(<5.7)
50-
extension URL: UnsafeSendable {}
51-
#elseif !canImport(Darwin)
49+
#if !canImport(Darwin)
5250
// As of Swift 5.7 and 5.8 swift-corelibs-foundation doesn't have `Sendable` annotations yet.
5351
extension URL: @unchecked Sendable {}
5452
#endif

Sources/Basics/Concurrency/SendableBox.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
14-
1513
import struct Foundation.Date
1614

1715
/// A `Sendable` storage that allows access from concurrently running tasks in
@@ -44,5 +42,3 @@ extension SendableBox where Value == Date {
4442
value = Date()
4543
}
4644
}
47-
48-
#endif

Sources/Basics/Concurrency/ThreadSafeArrayStore.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,4 @@ public final class ThreadSafeArrayStore<Value> {
8383
}
8484
}
8585

86-
#if swift(<5.7)
87-
extension ThreadSafeArrayStore: UnsafeSendable where Value: Sendable {}
88-
#else
8986
extension ThreadSafeArrayStore: @unchecked Sendable where Value: Sendable {}
90-
#endif

Sources/Basics/Concurrency/ThreadSafeBox.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,4 @@ extension ThreadSafeBox where Value == Int {
100100
}
101101
}
102102

103-
#if swift(<5.7)
104-
extension ThreadSafeBox: UnsafeSendable where Value: Sendable {}
105-
#else
106103
extension ThreadSafeBox: @unchecked Sendable where Value: Sendable {}
107-
#endif

Sources/Basics/Concurrency/ThreadSafeKeyValueStore.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,4 @@ public final class ThreadSafeKeyValueStore<Key, Value> where Key: Hashable {
9393
}
9494
}
9595

96-
#if swift(<5.7)
97-
extension ThreadSafeKeyValueStore: UnsafeSendable where Key: Sendable, Value: Sendable {}
98-
#else
9996
extension ThreadSafeKeyValueStore: @unchecked Sendable where Key: Sendable, Value: Sendable {}
100-
#endif

Sources/Basics/Concurrency/TokenBucket.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
14-
1513
import _Concurrency
1614
import DequeModule
1715

18-
// This type is already marked as `Sendable` in Swift 5.6 and later
19-
#if swift(<5.6)
20-
extension CheckedContinuation: UnsafeSendable {}
21-
#endif
22-
2316
/// Type modeled after a "token bucket" pattern, which is similar to a semaphore, but is built with
2417
/// Swift Concurrency primitives.
2518
public actor TokenBucket {
@@ -67,5 +60,3 @@ public actor TokenBucket {
6760
}
6861
}
6962
}
70-
71-
#endif // swift(>=5.5.2)

Sources/Basics/FileSystem/AsyncFileSystem.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
1413
import _Concurrency
1514

1615
import class TSCBasic.BufferedOutputByteStream
@@ -264,5 +263,3 @@ extension AsyncFileSystem {
264263
try self.removeFileTree(tempDirectory)
265264
}
266265
}
267-
268-
#endif // swift(>=5.5.2)

Sources/Basics/FileSystem/TemporaryFile.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212

1313
import _Concurrency
1414
import Foundation
15-
#if swift(>=5.7)
1615
@preconcurrency import TSCBasic
17-
#else
18-
import TSCBasic
19-
#endif
20-
21-
#if swift(>=5.5.2)
2216

2317
/// Creates a temporary directory and evaluates a closure with the directory path as an argument.
2418
/// The temporary directory will live on disk while the closure is evaluated and will be deleted when
@@ -86,8 +80,6 @@ public func withTemporaryDirectory<Result>(
8680
}
8781
}
8882

89-
#endif
90-
9183
private func createTemporaryDirectory(fileSystem: FileSystem, dir: AbsolutePath?, prefix: String) throws -> AbsolutePath {
9284
// This random generation is needed so that
9385
// it is more or less equal to generation using `mkdtemp` function

Sources/Basics/HTTPClient/HTTPClient.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
14-
1513
import _Concurrency
1614
import Foundation
1715
import DequeModule
@@ -251,5 +249,3 @@ public extension HTTPClient {
251249
)
252250
}
253251
}
254-
255-
#endif

Sources/Basics/HTTPClient/HTTPClientConfiguration.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// `Sendable` conformance on contained types requires Swift Concurrency back-deployment.
14-
#if swift(>=5.5.2)
15-
1613
import Foundation
1714

1815
public struct HTTPClientConfiguration: Sendable {
@@ -44,8 +41,6 @@ public struct HTTPClientConfiguration: Sendable {
4441
public var maxConcurrentRequests: Int?
4542
}
4643

47-
#endif
48-
4944
public enum HTTPClientRetryStrategy: Sendable {
5045
case exponentialBackoff(maxAttempts: Int, baseDelay: SendableTimeInterval)
5146
}

Sources/Basics/HTTPClient/HTTPClientRequest.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// `AsyncFileSystem` used by `HTTPClientRequest` requires Swift Concurrency back-deployment.
14-
#if swift(>=5.5.2)
15-
1613
import Foundation
1714

1815
import struct TSCBasic.AbsolutePath
@@ -101,5 +98,3 @@ public struct HTTPClientRequest: Sendable {
10198
}
10299
}
103100
}
104-
105-
#endif

Sources/Basics/HTTPClient/HTTPClientResponse.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
import Foundation
1414

15-
#if swift(<5.7)
16-
extension Data: UnsafeSendable {}
17-
#endif
18-
1915
public struct HTTPClientResponse : Sendable {
2016
public let statusCode: Int
2117
public let statusText: String?

Sources/Basics/HTTPClient/URLSessionHTTPClient.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ final class URLSessionHTTPClient {
2929
self.downloadTaskManager = DownloadTaskManager(configuration: configuration)
3030
}
3131

32-
#if swift(>=5.5.2)
33-
3432
@Sendable
3533
func execute(
3634
_ request: HTTPClient.Request,
@@ -62,8 +60,6 @@ final class URLSessionHTTPClient {
6260
}
6361
}
6462

65-
#endif
66-
6763
public func execute(
6864
_ request: LegacyHTTPClient.Request,
6965
progress: LegacyHTTPClient.ProgressHandler?,
@@ -350,8 +346,6 @@ extension URLRequest {
350346
}
351347
}
352348

353-
// For `HTTPClient` to be available we need Swift Concurrency back-deployment.
354-
#if swift(>=5.5.2)
355349
init(_ request: HTTPClient.Request) {
356350
self.init(url: request.url)
357351
self.httpMethod = request.method.string
@@ -363,7 +357,6 @@ extension URLRequest {
363357
self.timeoutInterval = interval
364358
}
365359
}
366-
#endif
367360
}
368361

369362
private extension HTTPURLResponse {

Sources/Basics/SQLite.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,9 @@ public final class SQLite {
299299
}
300300
}
301301

302-
#if swift(>=5.6)
303302
// Explicitly mark this class as non-Sendable
304303
@available(*, unavailable)
305304
extension SQLite: Sendable {}
306-
#endif
307305

308306
private func sqlite_callback(
309307
_ ctx: UnsafeMutableRawPointer?,

Sources/PackageRegistry/SignatureValidation.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
1413
import _Concurrency
15-
#endif
16-
1714
import Dispatch
1815
import struct Foundation.Data
1916

@@ -186,7 +183,6 @@ struct SignatureValidation {
186183
observabilityScope: ObservabilityScope,
187184
completion: @escaping (Result<SigningEntity?, Error>) -> Void
188185
) {
189-
#if swift(>=5.5.2)
190186
Task {
191187
do {
192188
let signatureStatus = try await SignatureProvider.status(
@@ -234,8 +230,5 @@ struct SignatureValidation {
234230
completion(.failure(RegistryError.failedToValidateSignature(error)))
235231
}
236232
}
237-
#else
238-
completion(.failure(InternalError("package signature validation not supported")))
239-
#endif
240233
}
241234
}

Sources/SPMTestSupport/MockHashAlgorithm.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,4 @@ public final class MockHashAlgorithm {
3333
}
3434
}
3535

36-
// Older compilers are unable to infer sendability for `Optional` closures even when those are `@Sendable`.
37-
#if swift(<5.6)
38-
extension MockHashAlgorithm: UnsafeSendable {}
39-
#endif
40-
4136
extension MockHashAlgorithm: HashAlgorithm {}

Tests/BasicsTests/FileSystem/AsyncFileSystemTests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
1413
import _Concurrency
1514

1615
@testable import Basics
@@ -107,5 +106,3 @@ final class AsyncFileSystemTests: XCTestCase {
107106
}
108107
}
109108
}
110-
111-
#endif // swift(>=5.5.2)

Tests/BasicsTests/FileSystem/TemporaryFileTests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
14-
1513
import XCTest
1614
import TSCBasic
1715

@@ -92,5 +90,3 @@ class TemporaryAsyncFileTests: XCTestCase {
9290
} catch {}
9391
}
9492
}
95-
96-
#endif

Tests/BasicsTests/FileSystem/VFSTests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import Basics
1414
import TSCBasic
1515
import XCTest
1616

17-
#if swift(>=5.5.2)
18-
1917
func testWithTemporaryDirectory(
2018
function: StaticString = #function,
2119
body: @escaping (AbsolutePath) async throws -> Void
@@ -34,8 +32,6 @@ func testWithTemporaryDirectory(
3432
}.value
3533
}
3634

37-
#endif
38-
3935
class VFSTests: XCTestCase {
4036
func testLocalBasics() throws {
4137
// tiny PE binary from: https://archive.is/w01DO

Tests/BasicsTests/HTTPClientTests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=5.5.2)
14-
1513
@testable import Basics
1614
import SPMTestSupport
1715
import XCTest
@@ -428,5 +426,3 @@ private func assertRequestHeaders(_ headers: HTTPClientHeaders, expected: HTTPCl
428426
private func assertResponseHeaders(_ headers: HTTPClientHeaders, expected: HTTPClientHeaders) {
429427
XCTAssertEqual(headers, expected, "expected headers to match")
430428
}
431-
432-
#endif

Tests/BasicsTests/URLSessionHTTPClientTests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ final class URLSessionHTTPClientTest: XCTestCase {
570570
}
571571

572572
// FIXME: remove this availability check when back-deployment is available on CI hosts.
573-
#if swift(>=5.5.2)
574573
func testAsyncHead() async throws {
575574
let configuration = URLSessionConfiguration.ephemeral
576575
configuration.protocolClasses = [MockURLProtocol.self]
@@ -964,7 +963,6 @@ final class URLSessionHTTPClientTest: XCTestCase {
964963
}
965964
}
966965
}
967-
#endif // swift(>=5.5.2)
968966
}
969967

970968
private class MockURLProtocol: URLProtocol {
@@ -977,11 +975,9 @@ private class MockURLProtocol: URLProtocol {
977975
self.onRequest(request.method.string, request.url, completion: completion)
978976
}
979977

980-
#if swift(>=5.5.2)
981978
static func onRequest(_ request: HTTPClientRequest, completion: @escaping Action) {
982979
self.onRequest(request.method.string, request.url, completion: completion)
983980
}
984-
#endif
985981

986982
static func onRequest(_ method: String, _ url: URL, completion: @escaping Action) {
987983
let key = Key(method, url)

Tests/FunctionalTests/ModuleAliasingFixtureTests.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import XCTest
2121
class ModuleAliasingFixtureTests: XCTestCase {
2222

2323
func testModuleDirectDeps1() throws {
24-
#if swift(<5.7)
25-
try XCTSkipIf(true, "Module aliasing is only supported on swift 5.7+")
26-
#endif
27-
2824
try fixture(name: "ModuleAliasing/DirectDeps1") { fixturePath in
2925
let pkgPath = fixturePath.appending(components: "AppPkg")
3026
let buildPath = pkgPath.appending(components: ".build", try UserToolchain.default.triple.platformBuildPathComponent(), "debug")
@@ -39,10 +35,6 @@ class ModuleAliasingFixtureTests: XCTestCase {
3935
}
4036

4137
func testModuleDirectDeps2() throws {
42-
#if swift(<5.7)
43-
try XCTSkipIf(true, "Module aliasing is only supported on swift 5.7+")
44-
#endif
45-
4638
try fixture(name: "ModuleAliasing/DirectDeps2") { fixturePath in
4739
let pkgPath = fixturePath.appending(components: "AppPkg")
4840
let buildPath = pkgPath.appending(components: ".build", try UserToolchain.default.triple.platformBuildPathComponent(), "debug")

Tests/PackageSigningTests/SigningTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import SPMTestSupport
2020
import func TSCBasic.tsc_await
2121
import X509
2222

23-
#if swift(>=5.5.2)
2423
final class SigningTests: XCTestCase {
2524
func testCMS1_0_0EndToEnd() async throws {
2625
let keyAndCertChain = try tsc_await { self.ecTestKeyAndCertChain(callback: $0) }
@@ -413,4 +412,3 @@ final class SigningTests: XCTestCase {
413412
}
414413
}
415414
}
416-
#endif

0 commit comments

Comments
 (0)