mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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 current PrintOptions 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 adopted `async`). 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.
28 KiB
28 KiB