-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Provide ability to use CheckedContinuation when suspending for an async ObjC call #68390
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
Merged
xedin
merged 7 commits into
swiftlang:main
from
xedin:checked-continuations-for-foreign-callbacks
Sep 9, 2023
Merged
Provide ability to use CheckedContinuation when suspending for an async ObjC call #68390
xedin
merged 7 commits into
swiftlang:main
from
xedin:checked-continuations-for-foreign-callbacks
Sep 9, 2023
Conversation
This file contains hidden or 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
…handler generator Instead of relying on `continuationType` for information, let's take it from the source.
…to checked continuations
… `CheckedContinuation`
Because `CheckedContinuation` is not a @Frozen struct we have to use `Any` to store it in @block_storage indirectly. If the flag is enabled, we'd emit a block storage with `Any` and initialize the existential with stack allocated `CheckedContinuation` formed from `UnsafeContinuation`. Inside of the completion handler `Any` is going to be projected and cast back to `CheckedContinuation`.
…t's using async continuations
…king continuations mode
xedin
commented
Sep 8, 2023
ktoso
approved these changes
Sep 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS looks good but not too clear on the objc bits :)
jckarter
approved these changes
Sep 8, 2023
@swift-ci please test |
@swift-ci please test source compatibility release |
Source compatibility suite failures are unrelated:
|
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.
Builds on @kavon's PR - #41772
To provide enhanced debugging and runtime checking for the correct usage
of continuations passed in a call to ObjC from Swift, this PR introduces a flag
for the
swift-frontend
that uses aCheckedContinuation
when calling anasync ObjC function from Swift. When enabled, the underlying block value
passed as a completion-handler is created using
CheckedContinuation
instead of just an
UnsafeContinuation
, which was what was used previously.The checked continuation ensures that the block is only invoked once.
As of now, the
swift-frontend
flag is-checked-async-objc-bridging={on, off}
Resolves: rdar://89930501