swift
1437acdf - Implement conditional feature suppression.

Commit
1 year ago
Implement conditional feature suppression. 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.
Author
Committer
Parents
Loading