|
34 | 34 | // imply the existence of earlier features. (This only needs to apply to |
35 | 35 | // suppressible features.) |
36 | 36 | // |
| 37 | +// If suppressing a feature in general is problematic, but it's okay to |
| 38 | +// suppress it for specific declarations, the feature can be made |
| 39 | +// conditionally suppressible. Declarations opt in to suppression with |
| 40 | +// the @_allowFeatureSuppression attribute. |
| 41 | +// |
37 | 42 | // BASELINE_LANGUAGE_FEATURE is the same as LANGUAGE_FEATURE, but is used |
38 | 43 | // for features that can be assumed to be available in any Swift compiler that |
39 | 44 | // will be used to process the textual interface files produced by this |
|
44 | 49 | # error define LANGUAGE_FEATURE before including Features.def |
45 | 50 | #endif |
46 | 51 |
|
| 52 | +// A feature that's both suppressible and experimental. |
| 53 | +// Delegates to whichever the includer defines. |
| 54 | +#ifndef SUPPRESSIBLE_EXPERIMENTAL_FEATURE |
| 55 | +# if defined(SUPPRESSIBLE_LANGUAGE_FEATURE) && \ |
| 56 | + defined(EXPERIMENTAL_FEATURE) |
| 57 | +# error ambiguous defines when including Features.def |
| 58 | +# elif defined(SUPPRESSIBLE_LANGUAGE_FEATURE) |
| 59 | +# define SUPPRESSIBLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \ |
| 60 | + SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, 0, #FeatureName) |
| 61 | +# else |
| 62 | +# define SUPPRESSIBLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \ |
| 63 | + EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) |
| 64 | +# endif |
| 65 | +#endif |
| 66 | + |
47 | 67 | #ifndef SUPPRESSIBLE_LANGUAGE_FEATURE |
48 | | -#define SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \ |
| 68 | +# define SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \ |
49 | 69 | LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
50 | 70 | #endif |
51 | 71 |
|
| 72 | +// A feature that's both conditionally-suppressible and experimental. |
| 73 | +// Delegates to whichever the includer defines. |
| 74 | +#ifndef CONDITIONALLY_SUPPRESSIBLE_EXPERIMENTAL_FEATURE |
| 75 | +# if defined(CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE) && \ |
| 76 | + defined(EXPERIMENTAL_FEATURE) |
| 77 | +# error ambiguous defines when including Features.def |
| 78 | +# elif defined(CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE) |
| 79 | +# define CONDITIONALLY_SUPPRESSIBLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \ |
| 80 | + CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, 0, #FeatureName) |
| 81 | +# else |
| 82 | +# define CONDITIONALLY_SUPPRESSIBLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \ |
| 83 | + EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) |
| 84 | +# endif |
| 85 | +#endif |
| 86 | + |
| 87 | +#ifndef CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE |
| 88 | +# define CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \ |
| 89 | + LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
| 90 | +#endif |
| 91 | + |
52 | 92 | #ifndef UPCOMING_FEATURE |
53 | 93 | # define UPCOMING_FEATURE(FeatureName, SENumber, Version) \ |
54 | 94 | LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName) |
@@ -301,5 +341,8 @@ EXPERIMENTAL_FEATURE(IsolatedAny, true) |
301 | 341 | #undef EXPERIMENTAL_FEATURE |
302 | 342 | #undef UPCOMING_FEATURE |
303 | 343 | #undef BASELINE_LANGUAGE_FEATURE |
| 344 | +#undef CONDITIONALLY_SUPPRESSIBLE_EXPERIMENTAL_FEATURE |
| 345 | +#undef CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE |
| 346 | +#undef SUPPRESSIBLE_EXPERIMENTAL_FEATURE |
304 | 347 | #undef SUPPRESSIBLE_LANGUAGE_FEATURE |
305 | 348 | #undef LANGUAGE_FEATURE |
0 commit comments