Skip to content

Relax escaping requirement for closures in Async{Lock|Mutex}#781

Open
jamieQ wants to merge 1 commit into
apple:mainfrom
jamieQ:relax-escaping-requirement
Open

Relax escaping requirement for closures in Async{Lock|Mutex}#781
jamieQ wants to merge 1 commit into
apple:mainfrom
jamieQ:relax-escaping-requirement

Conversation

@jamieQ

@jamieQ jamieQ commented Jun 26, 2026

Copy link
Copy Markdown

I was looking into why #696 was implemented, which was a fix for new warnings in the 6.4 compiler, and was confused why the diagnostic would be firing in the case it appeared to address. It turns out this was due to the AsyncMutex.withLock method taking an escaping closure parameter. However, the closure does not actually escape, so we can undo that prior workaround and make the API slightly more general by dropping the @escaping attribute. The same reasoning applies to AsyncLock as well, so for consistency I applied the change there too.

This does alter a public API though and I'm not sure what the source compatibility goals of this project are exactly, so let me know if you think that will be problematic.

The closures do not actually escape within the method bodies, so
drop `@escaping` from the parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant