Skip to content

[AST] Add a new attribute @hasAsyncAlternative #36027

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 1 commit into from
Feb 20, 2021

Conversation

bnbarham
Copy link
Contributor

This attribute marks a function has having an async alternative,
optionally providing the name of that function as a string. Intended to
be used to allow warnings when using a function with an async
alternative in an asynchronous context, to make the async refactorings
more accurate, and for documentation.

@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham requested a review from slavapestov February 18, 2021 01:23
@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 342947dc9da8cb579e6de5c76fe9b81746f7b9e3

@bnbarham
Copy link
Contributor Author

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 342947dc9da8cb579e6de5c76fe9b81746f7b9e3

This attribute marks a function has having an async alternative,
optionally providing the name of that function as a string. Intended to
be used to allow warnings when using a function with an async
alternative in an asynchronous context, to make the async refactorings
more accurate, and for documentation.
@bnbarham bnbarham force-pushed the hasasyncalternative branch from 342947d to 3a7bf23 Compare February 18, 2021 06:18
@bnbarham
Copy link
Contributor Author

Still an unrelated failure... had to update the module version anyway though (updated on main).

@swift-ci please test macOS platform

@bnbarham
Copy link
Contributor Author

@swift-ci please smoke test Linux platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3a7bf23

@bnbarham
Copy link
Contributor Author

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3a7bf23

@bnbarham
Copy link
Contributor Author

@swift-ci please test macOS platform

@bnbarham bnbarham requested a review from CodaFi February 20, 2021 00:37
@bnbarham bnbarham merged commit b7a6bcb into swiftlang:main Feb 20, 2021
@bnbarham bnbarham deleted the hasasyncalternative branch February 20, 2021 01:15
@@ -387,6 +387,9 @@ namespace swift {
ASTVerifierOverrideKind ASTVerifierOverride =
ASTVerifierOverrideKind::NoOverride;

/// Allow @hasAsyncAlternative attribute
bool EnableExperimentalHasAsyncAlternative = false;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need a flag for this. ConcurrencyOnly ensures that it can only be used when -enable-experimental-concurrency is provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, wasn't sure whether it being behind concurrency only was okay :). Good to know!

public:
/// An optional name of the async alternative function, where the name of the
/// attributed function is used otherwise.
const DeclNameRef Name;
Copy link
Member

Choose a reason for hiding this comment

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

We'll want type checking to resolve this to a Decl*, and serialization to serialize the Decl reference rather than the name (so clients don't have to resolve the Decl again).

etcwilde added a commit to etcwilde/swift that referenced this pull request Feb 25, 2021
This patch removes the feature flag for @hasAsyncAlternative since it's
already protected by the experimental concurrency flag and will go in
with the concurrency features.

This fixes one of Doug's comments on
swiftlang#36027.
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