|
14 | 14 | // features.
|
15 | 15 | //
|
16 | 16 | //
|
17 |
| -// LANGUAGE_FEATURE(FeatureName, IsAdoptable, SENumber, Description) |
| 17 | +// LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
18 | 18 | //
|
19 | 19 | // The LANGUAGE_FEATURE macro describes each named feature that is
|
20 | 20 | // introduced in Swift. It allows Swift code to check for a particular
|
21 | 21 | // feature with "#if $FeatureName" in source code.
|
22 | 22 | //
|
23 | 23 | // FeatureName: The name given to this feature to be used in source code,
|
24 | 24 | // e.g., AsyncAwait.
|
25 |
| -// IsAdoptable: Whether the feature implements adoption mode. |
26 |
| -// |
27 |
| -// If the feature is upcoming (source-breaking) and provides for a |
28 |
| -// mechanical code migration, it should implement adoption mode. |
29 |
| -// |
30 |
| -// Adoption mode is a feature-oriented code migration mechanism: a mode |
31 |
| -// of operation that should produce compiler warnings with attached |
32 |
| -// fix-its that can be applied to preserve the behavior of the code once |
33 |
| -// the upcoming feature is enacted. |
34 |
| -// These warnings must belong to a diagnostic group named after the |
35 |
| -// feature. Adoption mode itself *and* the fix-its it produces must be |
36 |
| -// source and binary compatible with how the code is compiled when the |
37 |
| -// feature is disabled. |
38 |
| -// |
39 | 25 | // SENumber: The number assigned to this feature in the Swift Evolution
|
40 | 26 | // process, or 0 if there isn't one.
|
41 | 27 | // Description: A string literal describing the feature.
|
|
106 | 92 |
|
107 | 93 | #ifndef SUPPRESSIBLE_LANGUAGE_FEATURE
|
108 | 94 | #define SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \
|
109 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/false, SENumber, \ |
110 |
| - Description) |
| 95 | + LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
111 | 96 | #endif
|
112 | 97 |
|
113 | 98 | #ifndef OPTIONAL_LANGUAGE_FEATURE
|
114 | 99 | #define OPTIONAL_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \
|
115 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/false, SENumber, Description) |
| 100 | + LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
116 | 101 | #endif
|
117 | 102 |
|
118 | 103 | // A feature that's both conditionally-suppressible and experimental.
|
|
133 | 118 | #ifndef CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE
|
134 | 119 | #define CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, \
|
135 | 120 | Description) \
|
136 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/false, SENumber, \ |
137 |
| - Description) |
| 121 | + LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
138 | 122 | #endif
|
139 | 123 |
|
140 | 124 | // An upcoming feature that supports adoption mode.
|
| 125 | +// |
| 126 | +// If the feature is source-breaking and provides for a |
| 127 | +// mechanical code migration, it should implement adoption mode. |
| 128 | +// |
| 129 | +// Adoption mode is a feature-oriented code migration mechanism: a mode |
| 130 | +// of operation that should produce compiler warnings with attached |
| 131 | +// fix-its that can be applied to preserve the behavior of the code once |
| 132 | +// the upcoming feature is enacted. |
| 133 | +// These warnings must belong to a diagnostic group named after the |
| 134 | +// feature. Adoption mode itself *and* the fix-its it produces must be |
| 135 | +// source and binary compatible with how the code is compiled when the |
| 136 | +// feature is disabled. |
141 | 137 | #ifndef ADOPTABLE_UPCOMING_FEATURE
|
142 | 138 | #if defined(UPCOMING_FEATURE)
|
143 | 139 | #define ADOPTABLE_UPCOMING_FEATURE(FeatureName, SENumber, Version) \
|
144 | 140 | UPCOMING_FEATURE(FeatureName, SENumber, Version)
|
145 | 141 | #else
|
146 | 142 | #define ADOPTABLE_UPCOMING_FEATURE(FeatureName, SENumber, Version) \
|
147 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/true, SENumber, \ |
148 |
| - #FeatureName) |
| 143 | + LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName) |
| 144 | + #endif |
| 145 | +#endif |
| 146 | + |
| 147 | +// See `ADOPTABLE_UPCOMING_FEATURE`. |
| 148 | +#ifndef ADOPTABLE_EXPERIMENTAL_FEATURE |
| 149 | + #if defined(EXPERIMENTAL_FEATURE) |
| 150 | + #define ADOPTABLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \ |
| 151 | + EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) |
| 152 | + #else |
| 153 | + #define ADOPTABLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \ |
| 154 | + LANGUAGE_FEATURE(FeatureName, 0, #FeatureName) |
149 | 155 | #endif
|
150 | 156 | #endif
|
151 | 157 |
|
152 | 158 | #ifndef UPCOMING_FEATURE
|
153 | 159 | #define UPCOMING_FEATURE(FeatureName, SENumber, Version) \
|
154 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/false, SENumber, \ |
155 |
| - #FeatureName) |
| 160 | + LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName) |
156 | 161 | #endif
|
157 | 162 |
|
158 | 163 | #ifndef EXPERIMENTAL_FEATURE
|
159 | 164 | // Warning: setting `AvailableInProd` to `true` on a feature means that the
|
160 | 165 | // flag cannot be dropped in the future.
|
161 | 166 | #define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \
|
162 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/false, 0, #FeatureName) |
| 167 | + LANGUAGE_FEATURE(FeatureName, 0, #FeatureName) |
163 | 168 | #endif
|
164 | 169 |
|
165 | 170 | #ifndef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
|
|
169 | 174 |
|
170 | 175 | #ifndef BASELINE_LANGUAGE_FEATURE
|
171 | 176 | #define BASELINE_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \
|
172 |
| - LANGUAGE_FEATURE(FeatureName, /*IsAdoptable=*/false, SENumber, \ |
173 |
| - Description) |
| 177 | + LANGUAGE_FEATURE(FeatureName, SENumber, Description) |
174 | 178 | #endif
|
175 | 179 |
|
176 | 180 | BASELINE_LANGUAGE_FEATURE(AsyncAwait, 296, "async/await")
|
@@ -242,17 +246,12 @@ BASELINE_LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
|
242 | 246 | SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
|
243 | 247 | BASELINE_LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
|
244 | 248 | CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
|
245 |
| -LANGUAGE_FEATURE(IsolatedAny2, /*IsAdoptable=*/false, 431, |
246 |
| - "@isolated(any) function types") |
247 |
| -LANGUAGE_FEATURE(ObjCImplementation, /*IsAdoptable=*/false, 436, |
248 |
| - "@objc @implementation extensions") |
249 |
| -LANGUAGE_FEATURE(NonescapableTypes, /*IsAdoptable=*/false, 446, |
250 |
| - "Nonescapable types") |
251 |
| -LANGUAGE_FEATURE(BuiltinEmplaceTypedThrows, /*IsAdoptable=*/false, 0, |
252 |
| - "Builtin.emplace typed throws") |
| 249 | +LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types") |
| 250 | +LANGUAGE_FEATURE(ObjCImplementation, 436, "@objc @implementation extensions") |
| 251 | +LANGUAGE_FEATURE(NonescapableTypes, 446, "Nonescapable types") |
| 252 | +LANGUAGE_FEATURE(BuiltinEmplaceTypedThrows, 0, "Builtin.emplace typed throws") |
253 | 253 | SUPPRESSIBLE_LANGUAGE_FEATURE(MemorySafetyAttributes, 458, "@unsafe attribute")
|
254 |
| -LANGUAGE_FEATURE(ValueGenerics, /*IsAdoptable=*/ false, 452, |
255 |
| - "Value generics feature (integer generics)") |
| 254 | +LANGUAGE_FEATURE(ValueGenerics, 452, "Value generics feature (integer generics)") |
256 | 255 |
|
257 | 256 | // Swift 6
|
258 | 257 | UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
|
@@ -521,6 +520,7 @@ EXPERIMENTAL_FEATURE(CompileTimeValues, true)
|
521 | 520 | #undef EXPERIMENTAL_FEATURE
|
522 | 521 | #undef UPCOMING_FEATURE
|
523 | 522 | #undef ADOPTABLE_UPCOMING_FEATURE
|
| 523 | +#undef ADOPTABLE_EXPERIMENTAL_FEATURE |
524 | 524 | #undef BASELINE_LANGUAGE_FEATURE
|
525 | 525 | #undef OPTIONAL_LANGUAGE_FEATURE
|
526 | 526 | #undef CONDITIONALLY_SUPPRESSIBLE_EXPERIMENTAL_FEATURE
|
|
0 commit comments