-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON/PropertyList coders userInfo should require Sendable values #764
Merged
jmschonfeld
merged 1 commit into
swiftlang:main
from
jmschonfeld:coder-sendable-ui-value
Feb 12, 2025
Merged
JSON/PropertyList coders userInfo should require Sendable values #764
jmschonfeld
merged 1 commit into
swiftlang:main
from
jmschonfeld:coder-sendable-ui-value
Feb 12, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci please test |
itingliu
approved these changes
Jul 25, 2024
iCharlesHu
approved these changes
Jul 25, 2024
Marking as draft at the moment while we wait on this one - we need to wait for a compiler fix to ensure this isn't source breaking to clients |
1238718
to
c93635f
Compare
@swift-ci please test |
c93635f
to
17427b6
Compare
@swift-ci please test |
Compiler issues have been addressed so we're ready to land this now. Rebased on |
Merged
2 tasks
stmontgomery
added a commit
to swiftlang/swift-testing
that referenced
this pull request
Feb 12, 2025
…#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.
bnbarham
added a commit
to bnbarham/sourcekit-lsp
that referenced
this pull request
Feb 13, 2025
swift-foundation recently landed a change (in swiftlang/swift-foundation#764) which requires any Sendable values in `JSONEncoder.userInfo`. This causes a build failure: ``` JSONRPCConnection.swift:370:50: error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol 368 | 369 | // Setup callback for response type. 370 | decoder.userInfo[.responseTypeCallbackKey] = { (id: RequestID) -> ResponseType.Type? in | |- error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol | `- note: a function type must be marked '@sendable' to conform to 'Sendable' 371 | guard let outstanding = self.outstandingRequests[id] else { 372 | logger.error("Unknown request for \(id, privacy: .public)") ``` Make the closure sendable (the decoding here is already guarded by a queue).
bnbarham
added a commit
to bnbarham/sourcekit-lsp
that referenced
this pull request
Feb 13, 2025
swift-foundation recently landed a change (in swiftlang/swift-foundation#764) which requires `any Sendable` values in `JSONEncoder.userInfo`. This causes a build failure: ``` JSONRPCConnection.swift:370:50: error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol 368 | 369 | // Setup callback for response type. 370 | decoder.userInfo[.responseTypeCallbackKey] = { (id: RequestID) -> ResponseType.Type? in | |- error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol | `- note: a function type must be marked '@sendable' to conform to 'Sendable' 371 | guard let outstanding = self.outstandingRequests[id] else { 372 | logger.error("Unknown request for \(id, privacy: .public)") ``` Make the closure sendable (the decoding here is already guarded by a queue).
bnbarham
added a commit
to bnbarham/sourcekit-lsp
that referenced
this pull request
Feb 13, 2025
swift-foundation recently landed a change (in swiftlang/swift-foundation#764) which requires `any Sendable` values in `JSONEncoder.userInfo`. This causes a build failure: ``` JSONRPCConnection.swift:370:50: error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol 368 | 369 | // Setup callback for response type. 370 | decoder.userInfo[.responseTypeCallbackKey] = { (id: RequestID) -> ResponseType.Type? in | |- error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol | `- note: a function type must be marked '@sendable' to conform to 'Sendable' 371 | guard let outstanding = self.outstandingRequests[id] else { 372 | logger.error("Unknown request for \(id, privacy: .public)") ``` Make the closure sendable (the decoding here is already guarded by a queue).
Reverted in #1167 because it broke Swift CI. |
bnbarham
added a commit
to bnbarham/sourcekit-lsp
that referenced
this pull request
Feb 13, 2025
swift-foundation recently landed a change (in swiftlang/swift-foundation#764) which requires `any Sendable` values in `JSONEncoder.userInfo`. This causes a build failure: ``` JSONRPCConnection.swift:370:50: error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol 368 | 369 | // Setup callback for response type. 370 | decoder.userInfo[.responseTypeCallbackKey] = { (id: RequestID) -> ResponseType.Type? in | |- error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol | `- note: a function type must be marked '@sendable' to conform to 'Sendable' 371 | guard let outstanding = self.outstandingRequests[id] else { 372 | logger.error("Unknown request for \(id, privacy: .public)") ``` Make the closure sendable, which is safe as we're only reading from `outstandingRequests` (where all our writes are guarded by the same queue that the decoding is on).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This requires that the userInfo values are
Sendable
since they are stored inSendable
types. The@preconcurrency
attribute ensures that this is not an ABI breaking change or a source breaking change for projects using the Swift 5 language mode.