Skip to content

Commit f6e3562

Browse files
committed
burp 1.0
1 parent d7cd3e0 commit f6e3562

File tree

1 file changed

+60
-75
lines changed

1 file changed

+60
-75
lines changed

proposals/NNNN-adoption-tooling-swift-features.md

+60-75
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ Many upcoming features have a mechanical migration, meaning the compiler can
1616
determine the exact source changes necessary to allow the code to compile under
1717
the upcoming feature while preserving the behavior of the code.
1818
This proposal seeks to improve the experience of enabling individual
19-
upcoming features by providing a mechanism for producing the necessary source
20-
code changes automatically for a given set of upcoming features that a
21-
programmer wants to enable.
19+
upcoming features by providing an integrated mechanism for producing the
20+
necessary source code changes automatically for a given set of upcoming
21+
features that a programmer wants to enable.
2222

2323
## Motivation
2424

25-
Adopting certain features is a time-consuming endeavor at the least.
2625
It is the responsibility of project maintainers to preserve source (and binary)
2726
compatibility both internally and externally for library clients when enabling
2827
an upcoming feature, which can be difficult or tedious without having tools to
@@ -38,21 +37,22 @@ intent.
3837
Is the developer expecting guidance on adopting an improvement?
3938
All the compiler knows to do when a feature is enabled is to compile code
4039
accordingly.
41-
This suffices if a feature merely supplants an existing syntactical construct
42-
or changes the behavior of existing code in strictly predictable ways because
43-
Swift can infer the need to suggest a fix just from spotting certain code
44-
patterns.
40+
If a upcoming feature supplants an existing grammatical construct or
41+
invalidates an existing behavior, the language rules alone suffice because
42+
Swift can consistently infer the irrefutable need to diagnose certain code
43+
patterns just by spotting them.
4544

4645
Needless to say, not all upcoming features fall under these criteria (and not
47-
all features are source-breaking in the first place). Consider
48-
[`DisableOutwardActorInference`][SE-0401], which changes actor isolation
49-
inference of a type that contains an actor-isolated property wrapper. There
50-
is no way for the programmer to specify that they'd like compiler fix-its to
51-
make the existing actor isolation inference explicit. If they enable the
52-
upcoming feature, their code will simply behave differently. This was a
53-
point of debate in the review of SE-0401, and the Language Steering Group
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]:
46+
all features are source-breaking in the first place).
47+
Consider [`DisableOutwardActorInference`][SE-0401], which changes actor
48+
isolation inference rules with respect to wrapped properties.
49+
There is no way for the programmer to specify that they'd like compiler fix-its
50+
to make the existing actor isolation inference explicit.
51+
If they enable the upcoming feature, their code will simply behave differently.
52+
This was a point of debate in the review of [SE-0401], and the Language
53+
Steering Group concluded that automatic migration tooling is the right way to
54+
address this particular workflow, as
55+
[noted in the acceptance notes][SE-0401-acceptance]:
5656

5757
> the Language Steering Group believes that separate migration tooling to
5858
> help programmers audit code whose behavior will change under Swift 6 mode
@@ -61,7 +61,7 @@ particular workflow, as [noted in the acceptance notes][SE-0401-acceptance]:
6161
6262
### Automation
6363

64-
Many existing and prospective upcoming features come with simple and reliable
64+
Many existing and prospective upcoming features account for simple and reliable
6565
migration paths to facilitate adoption:
6666

6767
* [`NonfrozenEnumExhaustivity`][SE-0192]: Restore exhaustivity with
@@ -80,31 +80,18 @@ migration paths to facilitate adoption:
8080
explicitly.
8181
* [`InternalImportsByDefault`][SE-0409]: `import X``public import X`.
8282
* [`GlobalConcurrency`][SE-0412]:
83-
- Convert the global variable to a `let` (or)
84-
- `@MainActor`-isolate it (or)
85-
- Mark it with `nonisolated(unsafe)`
83+
- Convert the global variable to a `let`, or
84+
- `@MainActor`-isolate it, or
85+
- Mark it with `nonisolated(unsafe)`.
8686
* [`MemberImportVisibility`][SE-0444]: Add explicit imports appropriately.
8787
* [`InferSendableFromCaptures`][SE-0418]: Suppress inference with coercions
8888
and type annotations.
8989
* [Inherit isolation by default for async functions][async-inherit-isolation-pitch]:
9090
Mark nonisolated functions with the proposed attribute.
9191

92-
Extending diagnostic metadata to include information that allows for
93-
recognizing these diagnostics and distinguishing semantics-preserving fix-its
94-
from alternative source changes will open up numerous opportunities for
95-
higher-level tools — ranging from the Swift package manager to IDEs — to
96-
implement powerful solutions for organizing, automating, and tuning feature
97-
adoption processes.
98-
99-
It is not always feasible or in line with language design principles for an
100-
upcoming feature to have a mechanical migration path.
101-
For example, the following upcoming features require manual migration to
102-
preserve semantics:
103-
104-
* [`DynamicActorIsolation`][SE-0423]
105-
* [`GlobalActorIsolatedTypesUsability`][SE-0434]
106-
* [`StrictConcurrency`][SE-0337]
107-
* [`IsolatedDefaultValues`][SE-0411]
92+
Application of these adjustments can be fully automated in favor of preserving
93+
behavior, saving time for more important tasks, such as identifying, auditing
94+
and testing code where a change in behavior is preferable.
10895

10996
## Proposed solution
11097

@@ -115,39 +102,34 @@ leveraged to build better supportive adoption experiences for developers.
115102
If enabling a feature communicates an intent to *enact* rules, adoption mode
116103
communicates an intent to *adopt* them.
117104
An immediate benefit of adoption mode is the capability to deliver source
118-
modifications that can be applied to preserve or improve the behavior of
119-
existing code whenever the feature provides for them.
105+
modifications that can be applied to preserve compatibility whenever the
106+
feature provides for them.
120107

121108
This proposal will support the set of existing upcoming features that
122109
have mechanical migrations, as described in the [Automation](#automation)
123110
section.
124111
All future proposals that introduce a new upcoming feature and provide a
125-
mechanical migration are expected to support adoption mode and detail its
126-
behavior in the *Source compatibility* section of the proposal.
112+
mechanical migration should support adoption mode and detail the migration
113+
paths in the *Source compatibility* section of the proposal.
127114

128115
## Detailed design
129116

130117
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
118+
mode, which is a new mode of building a project that will produce compiler
132119
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.
120+
of the code when the upcoming feature is enabled.
136121

122+
The action of enabling a previously disabled upcoming feature in adoption
123+
mode must not cause any new compiler errors or behavioral changes, and the
124+
fix-its produced must preserve compatibility.
125+
Compatibility here refers to both source and binary compatibility, as well as
126+
to behavior.
137127
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
128+
for a given upcoming feature, i.e., because the upcoming feature does not
139129
have a mechanical migration.
140130
A corresponding warning will be emitted in this case to avoid the false
141131
impression that the impacted source code is compatible with the feature.
142132

143-
Adoption mode should deliver guidance in the shape of regular diagnostics.
144-
For arbitrary upcoming features, adoption mode is expected to anticipate and
145-
call out any compatibility issues that result from enacting the feature,
146-
coupling diagnostic messages with counteracting compatible changes and helpful
147-
alternatives whenever feasible.
148-
Compatibility issues encompass both source and binary compatibility issues,
149-
including behavioral changes.
150-
151133
### Interface
152134

153135
#### Compiler
@@ -233,22 +215,22 @@ SwiftSetting.enableUpcomingFeature("InternalImportsByDefault", mode: .adoption)
233215
### Diagnostics
234216

235217
Diagnostics emitted in relation to a specific feature in adoption mode must
236-
belong to a diagnostic group named after the feature. The names of diagnostic
237-
groups can be displayed alongside diagnostic messages using
238-
`-print-diagnostic-groups` and used to associate messages with features.
218+
belong to a diagnostic group named after the feature.
219+
The names of diagnostic groups can be displayed alongside diagnostic messages
220+
using `-print-diagnostic-groups` and used to associate messages with features.
239221

240222
## Source compatibility
241223

242-
This proposal does not affect language rules. The described changes to the API
243-
surface are source-compatible.
224+
This proposal does not affect language rules.
225+
The described changes to the API surface are source-compatible.
244226

245227
## ABI compatibility
246228

247229
This proposal does not affect binary compatibility or binary interfaces.
248230

249231
## Implications on adoption
250232

251-
Entering or exiting adoption mode may affect behavior and is therefore a
233+
Entering or exiting adoption mode will affect behavior and is therefore a
252234
potentially source-breaking action.
253235

254236
## Future directions
@@ -257,22 +239,23 @@ potentially source-breaking action.
257239

258240
For some upcoming features, a source change which alters the semantics of
259241
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.
242+
from enabling an upcoming feature.
243+
For example, programmers might want to replace cases of `any P` with `some P`.
244+
Adoption tooling could support the option to produce source incompatible
245+
fix-its in cases where the compiler can detect that a different behavior might
246+
be more beneficial.
264247

265-
### Applications beyond migration
248+
### Applications beyond mechanical migration
266249

267-
Adoption mode can be extrapolated to additive features, such as
250+
Adoption mode can also be extrapolated to additive features, such as
268251
[typed `throws`][SE-0413] or [opaque parameter types][SE-0341], by providing
269252
actionable adoption tips.
270253
Additive features are hard-enabled and become an integral part of the language
271254
as soon as they ship.
272255
Many recent additive features are already integrated into the Swift feature
273256
model and kept around for the sole purpose of supporting
274-
[feature availability checks][feature-detection] in conditional compilation
275-
blocks.
257+
[feature availability checks][SE-0362-feature-detection] in conditional
258+
compilation blocks.
276259

277260
Another potential direction for adoption mode is promotion of best practices.
278261

@@ -288,8 +271,10 @@ is essential for future tools built around adoption mode:
288271
This can prove especially handy when multiple features are simultaneously
289272
enabled in adoption mode, or when similar diagnostic messages are caused by
290273
distinct features.
291-
* Fix-its that preserve semantics can be prioritized and auto-applied in
292-
previews.
274+
* Exposing the purpose of a fix-it can help developers make quicker decisions
275+
when offerred multiple fix-its.
276+
Furthermore, tools can take advantage of this information by favoring and
277+
auto-applying source-compatible fix-its.
293278

294279
### `swift adopt`
295280

@@ -301,9 +286,9 @@ with a command line interface similar to `git add --patch`.
301286

302287
### Naming
303288

304-
Perhaps the most intuitive alternative to "adoption" is "migration". We
305-
settled on the former because there is no reason for this concept to be limited
306-
to upcoming features or migrational changes.
289+
Perhaps the most intuitive alternative to "adoption" is "migration".
290+
We settled on the former because there is no reason for this concept to be
291+
limited to upcoming features or migrational changes.
307292

308293
## Acknowledgements
309294

@@ -326,9 +311,10 @@ Special thanks to Holly for her guidance throughout the draft stage.
326311
[SE-0352]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0352-implicit-open-existentials.md
327312
[SE-0354]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0354-regex-literals.md
328313
[SE-0362]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md
329-
[feature-detection]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md#feature-detection-in-source-code
314+
[SE-0362-feature-detection]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md#feature-detection-in-source-code
330315
[SE-0383]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md
331316
[SE-0401]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0401-remove-property-wrapper-isolation.md
317+
[SE-0401-acceptance]: https://forums.swift.org/t/accepted-with-modifications-se-0401-remove-actor-isolation-inference-caused-by-property-wrappers/66241
332318
[SE-0409]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md
333319
[SE-0411]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0411-isolated-default-values.md
334320
[SE-0413]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0413-typed-throws.md
@@ -338,4 +324,3 @@ Special thanks to Holly for her guidance throughout the draft stage.
338324
[SE-0434]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0434-global-actor-isolated-types-usability.md
339325
[SE-0444]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
340326
[async-inherit-isolation-pitch]: https://forums.swift.org/t/pitch-inherit-isolation-by-default-for-async-functions/74862
341-
[SE-0401-acceptance]: https://forums.swift.org/t/accepted-with-modifications-se-0401-remove-actor-isolation-inference-caused-by-property-wrappers/66241

0 commit comments

Comments
 (0)