Skip to content

Commit 03178b9

Browse files
authored
Merge pull request #461 from mattpolzin/feature/460/fix-external-loader-sendable-warning
Fix external loader sendable warning/error
2 parents 2e0bddf + 6177d03 commit 03178b9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Sources/OpenAPIKit/ExternalLoader.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
import OpenAPIKitCore
99
import Foundation
1010

11+
// Once we hit language version 6.2 we get warnings (errors for Swift 6
12+
// language mode) if the ExternalLoader is not a SendableMetatype. We just
13+
// split this conformance requirement out into a trivial base protocol to make
14+
// it easy to have different behavior for different language versions. Prior to
15+
// Swift 6.2, SendableMetatype is not even available.
16+
#if compiler(>=6.2.0)
17+
public protocol _ExternalLoaderMetatype: SendableMetatype {}
18+
#else
19+
public protocol _ExternalLoaderMetatype {}
20+
#endif
21+
1122
/// An `ExternalLoader` enables `OpenAPIKit` to load external references
1223
/// without knowing the details of what decoder is being used or how new internal
1324
/// references should be named.
14-
public protocol ExternalLoader where Message: Sendable {
25+
public protocol ExternalLoader: _ExternalLoaderMetatype where Message: Sendable {
1526
/// This can be anything that an implementor of this protocol wants to pass back from
1627
/// the `load()` function and have available after all external loading has been done.
1728
///

Sources/OpenAPIKit30/ExternalLoader.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
import OpenAPIKitCore
99
import Foundation
1010

11+
// Once we hit language version 6.2 we get warnings (errors for Swift 6
12+
// language mode) if the ExternalLoader is not a SendableMetatype. We just
13+
// split this conformance requirement out into a trivial base protocol to make
14+
// it easy to have different behavior for different language versions. Prior to
15+
// Swift 6.2, SendableMetatype is not even available.
16+
#if compiler(>=6.2.0)
17+
public protocol _ExternalLoaderMetatype: SendableMetatype {}
18+
#else
19+
public protocol _ExternalLoaderMetatype {}
20+
#endif
21+
1122
/// An `ExternalLoader` enables `OpenAPIKit` to load external references
1223
/// without knowing the details of what decoder is being used or how new internal
1324
/// references should be named.
14-
public protocol ExternalLoader where Message: Sendable {
25+
public protocol ExternalLoader: _ExternalLoaderMetatype where Message: Sendable {
1526
/// This can be anything that an implementor of this protocol wants to pass back from
1627
/// the `load()` function and have available after all external loading has been done.
1728
///

0 commit comments

Comments
 (0)