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
[SR-15238] Key paths are not "Sendable" #57560
Comments
@swift-ci create |
With Xcode 14.1 beta 3 with SWIFT_STRICT_CONCURRENCY = "targeted", I'm seeing a lot of warnings as below.
and I can't even tell where it's happening. |
@nh7a did you by any chance find out how to solve or at least suppress those warnings? |
I'm facing the same issue. Lot's of warnings for KeyPath non-sendable conformance in various files where there are no KeyPath what so ever... "Generic class 'KeyPath' does not conform to the 'Sendable' protocol" |
This is a significant pain point when using In particular the AttributedString APIs that use dynamic member lookup completely break: var string = AttributedString("Hello")
string.accessibilitySpeechSpellsOutCharacters = true Produces this error:
As mentioned by others in this issue, the diagnostics have no line/column information so it can be hard to pinpoint what line is causing the issue. Changing For AttributedString in particular, I've been able to work around it by using more verbose APIs: var attributes = AttributeContainer()
attributes[AttributeScopes.AccessibilityAttributes.SpellOutAttribute.self] = true
let string = AttributedString("Hello", attributes: attributes) But that's very non-obvious that you can even do this. |
This will be resolved with SE-0418. You can test it out using a main development snapshot and enabling |
Thanks for the good news @hborla will it be included in 5.10? If not, is it possible for it to be cherry-picked? |
This reverts commit 96ebad3. Revert until this bug fixed apple/swift#57560
Hello everyone, I wanted to share a workaround specifically for suppressing the non-Sendable warning for KeyPaths in concurrent Swift code: extension KeyPath: @unchecked Sendable {} This approach is targeted solely at the Sendable conformance warning for KeyPaths and should be used cautiously as a temporary solution. It allows continued development without the immediate need to refactor large codebases, awaiting a more permanent resolution. Looking forward to any input or better alternatives from the community. Best, |
Environment
Swift 5.5+ (with -Xfrontend -warn-concurrency)
Additional Detail from JIRA
md5: e9831dccbc5222ce92d77b619d62c314
Issue Description:
Key paths cannot be captured inside code that should be concurrently executable. To repro, try compiling the following code with the
-Xfrontend -warn-concurrency
build flag.While the proposal suggests that key paths should conform to sendable (except for subscripts in which the referenced types are not sendable), I do not see any conformance in the repo.
The text was updated successfully, but these errors were encountered: