Fix and generalize the printing of suppressible features #41399
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix and generalize the printing of suppressible features, and make
@_unsafeInheritExecutor
a suppressible feature.Some language features are required in order to parse a declaration correctly, but some can safely be ignored. For the latter, we'd like the module interface to simply contain the declaration twice, once with the feature and once without. Some basic support for that was already added for the
SpecializeAttributeWithAvailability
feature, but it didn't interact correctly with required features that might be checked in the same#if
clause (it simply introduced an#else
), and it wasn't really set up to allow multiple features to be handled this way. There were also a few other places that weren't updated to handle this, presumably because they never coincided with a@_specialize
attribute.Introduce the concept of a suppressible feature, which is anything that the
ASTPrinter
can modify the currentPrintOptions
in order to suppress. Restructure the printing of compatibility checks so that we can print the body multiple times with different settings. Print required feature checks in an outer#if...#endif
, then perform a separate#if...#else...#endif
within if we have suppressible features. If there are multiple suppressible features, check for the most recent first, on the assumption that it will imply the rest; then perform subsequent checks with an#elsif
clause.This should be a far more solid foundation on which to build compatibility checks in the future.
@_unsafeInheritExecutor
needs to be suppressible because it's been added to some rather important existing APIs. Simply suppressing the entire decl will effectively block old tools from using a new SDK to build many existing projects (if they've adoptedasync
). Dropping the attribute changes the semantics of these functions, but only if the compiler features the SE-0338 scheduling change; this is a very narrow window of main-branch development builds of the tools, none of which were officially released.