Skip to content

Commit b4e0a27

Browse files
authored
Fix compilation with Swift 5.5.0 and 5.5.1 (#2234)
1 parent ece5057 commit b4e0a27

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Sources/NIOCore/SocketAddresses.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension SocketAddressError {
7575
public enum SocketAddress: CustomStringConvertible, NIOSendable {
7676

7777
/// A single IPv4 address for `SocketAddress`.
78-
public struct IPv4Address: NIOSendable {
78+
public struct IPv4Address {
7979
private let _storage: Box<(address: sockaddr_in, host: String)>
8080

8181
/// The libc socket address for an IPv4 address.
@@ -90,7 +90,7 @@ public enum SocketAddress: CustomStringConvertible, NIOSendable {
9090
}
9191

9292
/// A single IPv6 address for `SocketAddress`.
93-
public struct IPv6Address: NIOSendable {
93+
public struct IPv6Address {
9494
private let _storage: Box<(address: sockaddr_in6, host: String)>
9595

9696
/// The libc socket address for an IPv6 address.
@@ -560,6 +560,16 @@ extension SocketAddress: Equatable {
560560
}
561561
}
562562

563+
#if compiler(>=5.5.2)
564+
extension SocketAddress.IPv4Address: Sendable {}
565+
extension SocketAddress.IPv6Address: Sendable {}
566+
#elseif compiler(>=5.5)
567+
// Implicit conformance of tuples to Sendable interacts poorly with conditional conformance of Sendable in Swift <=5.5.1
568+
// https://github.com/apple/swift/issues/57346
569+
extension SocketAddress.IPv4Address: @unchecked Sendable {}
570+
extension SocketAddress.IPv6Address: @unchecked Sendable {}
571+
#endif
572+
563573
/// We define an extension on `SocketAddress` that gives it an elementwise hashable conformance, using
564574
/// only the elements defined on the structure in their man pages (excluding lengths).
565575
extension SocketAddress: Hashable {

Sources/NIOHTTP1/HTTPTypes.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ extension HTTPHeaders {
298298
/// field when needed. It also supports recomposing headers to a maximally joined
299299
/// or split representation, such that header fields that are able to be repeated
300300
/// can be represented appropriately.
301-
public struct HTTPHeaders: CustomStringConvertible, ExpressibleByDictionaryLiteral, NIOSendable {
301+
public struct HTTPHeaders: CustomStringConvertible, ExpressibleByDictionaryLiteral {
302302
@usableFromInline
303303
internal var headers: [(String, String)]
304304
internal var keepAliveState: KeepAliveState = .unknown
@@ -497,6 +497,14 @@ public struct HTTPHeaders: CustomStringConvertible, ExpressibleByDictionaryLiter
497497
}
498498
}
499499

500+
#if compiler(>=5.5.2)
501+
extension HTTPHeaders: Sendable {}
502+
#elseif compiler(>=5.5)
503+
// Implicit conformance of tuples to Sendable interacts poorly with conditional conformance of Sendable in Swift <=5.5.1
504+
// https://github.com/apple/swift/issues/57346
505+
extension HTTPHeaders: @unchecked Sendable {}
506+
#endif
507+
500508
extension HTTPHeaders {
501509

502510
/// The total number of headers that can be contained without allocating new storage.

0 commit comments

Comments
 (0)