Skip to content

Commit e1fd7c7

Browse files
authored
Require sendable userInfo values in JSON.withEncoding(of:userInfo:_:) (#955)
swift-foundation recently landed a change (in swiftlang/swift-foundation#764) which requires `any Sendable` values in `JSONEncoder.userInfo`. This causes a build failure in swift-testing: ``` JSON.swift:44:28: error: type 'Any' does not conform to the 'Sendable' protocol 42 | 43 | // Set user info keys that clients want to use during encoding. 44 | encoder.userInfo.merge(userInfo, uniquingKeysWith: { _, rhs in rhs}) | `- error: type 'Any' does not conform to the 'Sendable' protocol ``` This PR adjusts our `userInfo:` parameter require `any Sendable` values. The values we were passing to this utility were already sendable, luckily. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 7493d6e commit e1fd7c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/Testing/Support/JSON.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enum JSON {
2929
/// - Returns: Whatever is returned by `body`.
3030
///
3131
/// - Throws: Whatever is thrown by `body` or by the encoding process.
32-
static func withEncoding<R>(of value: some Encodable, userInfo: [CodingUserInfoKey: Any] = [:], _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
32+
static func withEncoding<R>(of value: some Encodable, userInfo: [CodingUserInfoKey: any Sendable] = [:], _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
3333
#if canImport(Foundation)
3434
let encoder = JSONEncoder()
3535

0 commit comments

Comments
 (0)