Skip to content

[5.5][Refactoring] Add @completionHandlerAsync to sync function #37418

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
merged 2 commits into from
May 14, 2021

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented May 14, 2021

Cherry-picks #37358 (to avoid a merge conflict) and #37417


When adding an async alternative, add the @completionHandlerAsync
attribute to the sync function. Check for this attribute in addition to
the name check, ie. convert a call if the callee has either
@completionHandlerAsync or a name that is completion-handler-like name.

The addition of the attribute is currently gated behind the experimental
concurrency flag.

Resolves rdar://77486504

@bnbarham bnbarham changed the title [Refactoring] Add @completionHandlerAsync to sync function [5.5][Refactoring] Add @completionHandlerAsync to sync function May 14, 2021
@bnbarham bnbarham added the r5.5 label May 14, 2021
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b73c4f87080e97afa22edeed1fc066331c0b8aa4

@bnbarham
Copy link
Contributor Author

@swift-ci please test Linux platform

atrick and others added 2 commits May 14, 2021 20:22
Fixes:
    sys.stdout.write(dump_text_output)
TypeError: write() argument must be str, not bytes
When adding an async alternative, add the @completionHandlerAsync
attribute to the sync function. Check for this attribute in addition to
the name check, ie. convert a call if the callee has either
@completionHandlerAsync or a name that is completion-handler-like name.

The addition of the attribute is currently gated behind the experimental
concurrency flag.

Resolves rdar://77486504
@bnbarham bnbarham force-pushed the 5.5-cherry-rdar77486504 branch from b73c4f8 to 3c0bb38 Compare May 14, 2021 10:26
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham
Copy link
Contributor Author

@swift-ci please nominate

--- CCC ---

Explanation: Add a "@completionHandlerAsync" attribute to the sync function when performing the "Add Async Alternative" refactoring and experimental concurrency features are enabled with -enable-experimental-concurrency. Have the function conversion check if this attribute is on the callee of a callsite when deciding whether to convert it (in addition to the existing name check).

Adding the attribute also enables a warning when that function is used in an async context (already used for implicitly imported ObjectiveC async functions).

Radar/SR Issue: rdar://77486504

Risk: Very low - only affects the async refactoring and only when experimental concurrency features are enabled.

Testing: Added new test cases to the refactoring test suite

@bnbarham bnbarham requested review from akyrtzi and airspeedswift May 14, 2021 14:10
@akyrtzi akyrtzi merged commit 4d545d9 into swiftlang:release/5.5 May 14, 2021
@bnbarham bnbarham deleted the 5.5-cherry-rdar77486504 branch May 14, 2021 22:54
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.5 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants