Skip to content

Commit 6fa695d

Browse files
authored
Fix warnings in Swift 6.2 about non-sendable types in isolated closures (#1233)
1 parent cd4c34c commit 6fa695d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

Sources/SwiftDocC/DocumentationService/ExternalReferenceResolverServiceClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ExternalReferenceResolverServiceClient {
4242
self.convertRequestIdentifier = convertRequestIdentifier
4343
}
4444

45-
func sendAndWait(_ request: some Codable) throws -> Data {
45+
func sendAndWait(_ request: some Codable & SendableMetatype) throws -> Data {
4646
let resultGroup = DispatchGroup()
4747

4848
var result: Result<Data?, Error>?

Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -20,7 +20,7 @@ private let useConcurrentCollectionExtensions = true
2020
private let useConcurrentCollectionExtensions = false
2121
#endif
2222

23-
extension Collection where Index == Int {
23+
extension Collection where Index == Int, Self: SendableMetatype {
2424

2525
/// Concurrently transforms the elements of a collection.
2626
/// - Parameters:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
// In Swift 6.2, metatypes are no longer sendable by default (SE-0470).
12+
// Instead a type needs to conform to `SendableMetatype` to indicate that its metatype is sendable.
13+
//
14+
// However, `SendableMetatype` doesn't exist before Swift 6.1 so we define an internal alias to `Any` here.
15+
// This means that conformances to `SendableMetatype` has no effect before 6.2 indicates metatype sendability in 6.2 onwards.
16+
//
17+
// Note: Adding a protocol requirement to a _public_ API is a breaking change.
18+
19+
#if compiler(<6.2)
20+
typealias SendableMetatype = Any
21+
#endif

0 commit comments

Comments
 (0)