A couple weeks ago, @Douglas_Gregor pitched some changes which tried to tackle some of the problems involved in adopting
Sendable checking in a module when some of your clients or dependencies may not have updated yet. I had some concerns about how that pitch’s approach might break or hide bugs when modules were eventually updated, as well as with how Objective-C libraries would be able to control the sendability of their types.
Doug agreed that these might be issues, so he asked me to write up a new pitch incorporating solutions for them. The tl;dr is:
@predatesConcurrencyis still roughly as Doug had it, except that it also covers global actor attributes, and Objective-C declarations are imported as predating concurrency.
When you import something that should be
Sendablebut the module has not been updated to make it
Sendableyet, you can work around this by using
@Sendable importto silence concurrency diagnostics related to that module. When that module later updates, you’ll either get a warning suggest you remove
@Sendable(if all is well) or you’ll get warnings about any concurrency bugs revealed by the module’s update (but they will not be hard errors, so you can keep building your project with the bugs it already had until you find time to fix them).
You can mark Objective-C type declarations with
__attribute__((swift_attr(“@Sendable”)))to make them
__attribute__((swift_attr(“@_nonSendable”)))to give them an unavailable
Sendableconformance (like Doug discussed in Improving Sendable yesterday). It should be possible to use Clang pragmas to provide a region-based auditing experience similar to nullability annotations.
I’d love to hear your feedback on this new approach.
Edit: In response to feedback, we'll be going back to
-warn-concurrency and using
@predatesConcurrency import instead of