@@ -52,7 +52,7 @@ make the existing actor isolation inference explicit. If they enable the
52
52
upcoming feature, their code will simply behave differently. This was a
53
53
point of debate in the review of SE-0401, and the Language Steering Group
54
54
concluded that automatic migration tooling is the right way to address this
55
- particular workflow, as [ noted in the acceptance notes] [ SE-0401-acceptance:
55
+ particular workflow, as [ noted in the acceptance notes] [ SE-0401-acceptance ] :
56
56
57
57
> the Language Steering Group believes that separate migration tooling to
58
58
> help programmers audit code whose behavior will change under Swift 6 mode
@@ -127,18 +127,19 @@ behavior in the *Source compatibility* section of the proposal.
127
127
128
128
## Detailed design
129
129
130
- ### Behavior
130
+ Upcoming features that have mechanical migrations will support an adoption
131
+ mode, which is a a new mode of building a project that will produce compiler
132
+ warnings with attached fix-its that can be applied to preserve the behavior
133
+ of the code when the upcoming feature is enabled. Adoption mode must not
134
+ cause any new compiler errors, and the fix-its produced must preserve the
135
+ source compatibility and behavior of the code.
131
136
132
- The action of enabling a previously disabled source-breaking feature in adoption
133
- mode per se must not cause compilation errors.
134
- Additionally, this action will have no effect if the mode is not supported .
137
+ Additionally, this action will have no effect if the mode is not supported
138
+ for a given upcoming feature, i,e. because the upcoming feature does not
139
+ have a mechanical migration .
135
140
A corresponding warning will be emitted in this case to avoid the false
136
141
impression that the impacted source code is compatible with the feature.
137
142
138
- > [ !NOTE]
139
- > Experimental features can be both additive and source-breaking.
140
- > Upcoming features are necessarily source-breaking.
141
-
142
143
Adoption mode should deliver guidance in the shape of regular diagnostics.
143
144
For arbitrary upcoming features, adoption mode is expected to anticipate and
144
145
call out any compatibility issues that result from enacting the feature,
@@ -147,17 +148,6 @@ alternatives whenever feasible.
147
148
Compatibility issues encompass both source and binary compatibility issues,
148
149
including behavioral changes.
149
150
150
- Note that adoption mode does not provide any new general guarantees in respect
151
- to fix-its.
152
- We cannot promise to offer exclusively compatible modifications.
153
- Besides the impact of a change on dependent source code being generally
154
- unpredictable, it can be reasonable to couple compatible fix-its with
155
- potentially incompatible, albeit better, alternatives, as in ` any P ` → ` some P ` .
156
- The same stands for provision of modifications — features might not have a
157
- mechanical migration path, and the compiler remains inherently limited in the
158
- extent to which it can make assumptions about what is helpful or best for the
159
- programmer.
160
-
161
151
### Interface
162
152
163
153
#### Compiler
@@ -263,6 +253,15 @@ potentially source-breaking action.
263
253
264
254
## Future directions
265
255
256
+ ### Producing source incompatible fix-its
257
+
258
+ For some upcoming features, a source change which alters the semantics of
259
+ the program is a more desirable approach to addressing an error that comes
260
+ from enabling an upcoming feature. For example, programmers might want to
261
+ replace cases of ` any P ` with ` some P ` . Adoption tooling could support the
262
+ option to produce source incompatible fix-its in cases where the compiler
263
+ can detect that a different behavior might be more beneficial.
264
+
266
265
### Applications beyond migration
267
266
268
267
Adoption mode can be extrapolated to additive features, such as
0 commit comments