Skip to content

Allow declarations to opt in to suppressing @isolated(any) instead of suppressing the entire declaration #72008

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 3 commits into from
Mar 2, 2024

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Mar 1, 2024

This PR also includes a significant NFC improvement to how we use suspended diagnostics in the parser.

@rjmccall
Copy link
Contributor Author

rjmccall commented Mar 1, 2024

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-any-feature-suppression branch from 75e6603 to aa8dea7 Compare March 1, 2024 18:36
@rjmccall
Copy link
Contributor Author

rjmccall commented Mar 1, 2024

@swift-ci Please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Could you also add a test case for this in the new parser?

@rjmccall
Copy link
Contributor Author

rjmccall commented Mar 1, 2024

@swift-ci Please test macOS

rjmccall added 3 commits March 1, 2024 22:09
The goal is to have a lightweight way to pass an unapplied
diagnostic to general routines.  Constructing a Diagnostic
is quite expensive as something we're potentially doing in
hot paths, as opposed to just when we're actually emitting
the diagnostic.  This design allows the expense to be delayed
until we need it.

I've also optimized the Diagnostic constructor to avoid
copying arguments unnecessarily; this is a relatively small
expense, since arguments are POD, but there's really no good
reason not to do it.
Our standard conception of suppressible features assumes we should
always suppress the feature if the compiler doesn't support it.
This presumes that there's no harm in suppressing the feature, and
that's a fine assumption for features that are just adding information
or suppressing new diagnostics.  Features that are semantically
relevant, maybe even ABI-breaking, are not a good fit for this,
and so instead of reprinting the decl with the feature suppressed,
we just have to hide the decl entirely.  The missing middle here
is that it's sometimes useful to be able to adopt a type change
to an existing declaration, and we'd like older compilers to be
able to use the older version of the declaration.  Making a type
change this way is, of course, only really acceptable for
@_alwaysEmitIntoClient declarations; but those represent quite a
few declarations that we'd like to be able to refine the types of.

Rather than trying to come up with heuristics based on
@_alwaysEmitIntoClient or other sources of information, this design
just requires the declaration to opt in with a new attribute,
@_allowFeatureSuppress.  When a declaration opts in to suppression
for a conditionally-suppressible feature, the printer uses the
suppression serially-print-with-downgraded-options approach;
otherwise it uses the print-only-if-feature-is-available approach.
@rjmccall rjmccall force-pushed the isolated-any-feature-suppression branch from aa8dea7 to fc538f3 Compare March 2, 2024 03:10
@rjmccall
Copy link
Contributor Author

rjmccall commented Mar 2, 2024

@swift-ci Please smoke test

@rjmccall
Copy link
Contributor Author

rjmccall commented Mar 2, 2024

@swift-ci Please smoke test Linux

@rjmccall rjmccall merged commit a68adb9 into swiftlang:main Mar 2, 2024
@rjmccall rjmccall deleted the isolated-any-feature-suppression branch March 2, 2024 08:07
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.

2 participants