Skip to content

Disallow async IBAction methods #59205

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 5 commits into from
Jun 16, 2022

Conversation

etcwilde
Copy link
Member

@etcwilde etcwilde commented Jun 1, 2022

The IBAction signature does not allow completion handlers, so making
IBAction methods async doesn't make sense. Disallowing it statically so
it doesn't just break people when they try.

Resolves: rdar://83259194

@etcwilde etcwilde requested review from slavapestov and beccadax June 1, 2022 19:28
@etcwilde
Copy link
Member Author

etcwilde commented Jun 1, 2022

@swift-ci please test

Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have the right idea, but I have some nitpicky requests/suggestions to make.

etcwilde added 3 commits June 2, 2022 10:14
The IBAction signature does not allow completion handlers, so making
IBAction methods async doesn't make sense. Disallowing it statically so
it doesn't just break people when they try.
This patch merges the two diagnostics complaining about asynchronous
function declarations with incompatible attributes. The two are cdecl
and ibaction at the moment.
This adds a note with a possible way to fix the issue, recommending
removing the `async` effect and wrapping the body of the function in a
task.
@etcwilde etcwilde force-pushed the ewilde/no-async-ibactions branch from d7a97ac to 103fca9 Compare June 5, 2022 06:04
@etcwilde
Copy link
Member Author

etcwilde commented Jun 5, 2022

@swift-ci please test

etcwilde added 2 commits June 5, 2022 10:06
This patch teaches the compiler to emit a fix-it to automatically wrap
everything in the function in a Task and remove the effects from the
function declaration.
@etcwilde etcwilde force-pushed the ewilde/no-async-ibactions branch from 103fca9 to 129b9c0 Compare June 5, 2022 17:07
@etcwilde
Copy link
Member Author

etcwilde commented Jun 5, 2022

@swift-ci please test

@etcwilde etcwilde requested a review from beccadax June 5, 2022 22:48
Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thank you!

@etcwilde
Copy link
Member Author

@swift-ci please test and merge

@swift-ci swift-ci merged commit f755904 into swiftlang:main Jun 16, 2022
@etcwilde etcwilde deleted the ewilde/no-async-ibactions branch June 17, 2022 15:12
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.

4 participants