Skip to content
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

[swift2objc] Support the async annotation #1779

Merged
merged 2 commits into from
Dec 3, 2024
Merged

[swift2objc] Support the async annotation #1779

merged 2 commits into from
Dec 3, 2024

Conversation

liamappelbe
Copy link
Contributor

This is implemented in pretty much exactly the same way as throws. Added a CanAsync interface, started parsing the annotation in parseFunctionInfo, and added the annotation to the generated code. The wrapper method gets an async annotation, and when invoking the wrapped method it must await the result.

Also like throws, there are edge cases where async APIs can't be marked with @objc. Support for these edge cases will be implemented later. See #1778

Fixes #1773

@coveralls
Copy link

Coverage Status

coverage: 88.759% (-0.01%) from 88.77%
when pulling dedbf1a on async
into 4b03d95 on main.


String generateAnnotations(Declaration decl) {
final annotations = StringBuffer();
if (decl is CanAsync && (decl as CanAsync).async) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Promotion isn't working here for some reason, so need the as.

Ideally I'd be able to do this with generics, like String generateAnnotations<T extends CanAsync, CanThrow> (T decl) {, but Dart doesn't allow that yet: dart-lang/language#2709

@liamappelbe liamappelbe merged commit 3210a79 into main Dec 3, 2024
6 checks passed
@liamappelbe liamappelbe deleted the async branch December 3, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[swift2objc] Support async annotation
3 participants