Skip to content

Commit f65f162

Browse files
Revise SE-0441 to reflect changes in accepted proposal
1 parent b3d79af commit f65f162

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

proposals/0441-formalize-language-mode-terminology.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
The term "Swift version” can refer to either the toolchain/compiler version or the language mode. This ambiguity is a consistent source of confusion. This proposal formalizes the term _language mode_ in tool options and APIs.
1212

1313
## Proposed Solution
14-
The proposed solution is to use the term _language mode_ for the appropriate Swift compiler option and Swift Package Manager APIs. Use of "Swift version" to refer to language mode will be deprecated or obsoleted as needed.
14+
The proposed solution is to use the term _language mode_ for the appropriate Swift compiler option and Swift Package Manager APIs. Use of "Swift version" to refer to language mode will be deprecated.
1515

1616
### Terminology
1717
The term _language mode_ has been consistently used to describe this compiler feature since it was introduced with Swift 4.0 and is an established term of art in the Swift community.
@@ -49,7 +49,7 @@ Add a new `init` method to `Package` with the following changes from the current
4949
- The parameter `swiftLanguageVersions` is renamed to `swiftLanguageModes`
5050
- The parameter type is now an optional array of `SwiftLanguageMode` values instead of `SwiftVersion` values
5151

52-
The existing init method will be marked as `obsoleted` and `renamed` allowing the compiler to provide a fix-it.
52+
The existing init method will be marked as `deprecated` and `renamed` allowing the compiler to provide a fix-it. It will also have the @_disfavoredOverload attribute added to allow the compiler to disambiguate.
5353

5454
#### 2. Rename `swiftLanguageVersions` property to `swiftLanguageModes`
5555
Rename the public `Package` property `swiftLanguageVersions` to `swiftLanguageModes`. Add a `swiftLanguageVersions` computed property that accesses `swiftLanguageModes` for backwards compatibility.
@@ -104,7 +104,7 @@ The `-swift-version` option will be suppressed from the top-level help of the co
104104
### Swift Package Manager
105105
Proposed Swift Package Manager API changes are limited to manifests \>= 6.0:
106106

107-
### New Package init method and obsoleted init method
107+
### New Package init method and deprecated init method
108108
A new `init` method will be added to `Package` that renames the `swiftLanguageVersions` parameter to `swiftLanguageModes` with the type of the parameter being an optional array of `SwiftLanguageMode` values instead of `SwiftVersion` values:
109109

110110
```swift
@@ -123,10 +123,11 @@ Package(
123123
```
124124

125125

126-
The existing init method will be marked as `obsoleted` and `renamed`, allowing the compiler to provide a fix-it:
126+
The existing init method will be marked as `deprecated` and `renamed`, allowing the compiler to provide a fix-it. It will also be annotated with `@_disfavoredOverload` to disambiguate the new and existing init methods:
127127

128128
```
129-
@available(_PackageDescription, introduced: 5.3, obsoleted: 6, renamed:
129+
@_disfavoredOverload
130+
@available(_PackageDescription, introduced: 5.3, deprecated: 6, renamed:
130131
"init(name:defaultLocalization:platforms:pkgConfig:providers:products:
131132
dependencies:targets:swiftLanguageModes:cLanguageStandard:
132133
cxxLanguageStandard:)")
@@ -139,8 +140,8 @@ cxxLanguageStandard:)")
139140
) {
140141
```
141142
142-
#### Obsoleting existing init method
143-
The existing method must be obsoleted because the two methods are ambiguous when the default value for `swiftLanguageVersions` / `swiftLanguageModes` is used:
143+
#### Deprecating the existing init method by making it a disfavored overload
144+
In order to deprecate the existing method instead of marking it obsoleted, the existing method needs to be annotated with the `@_disfavoredOverlaod` attribute. This is because the two methods are ambiguous when the default value for `swiftLanguageVersions` / `swiftLanguageModes` is used:
144145
145146
```
146147
Package ( // Error: Ambiguous use of 'init'
@@ -150,7 +151,7 @@ Package ( // Error: Ambiguous use of 'init'
150151
)
151152
```
152153
153-
This follows the same approach used by all past revisions of the Package `init` method.
154+
Adding the `@_disfavoredOverlaod` attribute allows the compiler to disambiguate between the two methods.
154155
155156
See the **Source compatibility** section for more details about this change.
156157
@@ -212,11 +213,11 @@ public struct SwiftSetting {
212213
```
213214
214215
## Source compatibility
215-
The new Package `init` method and obsoleting of the existing `init` method will cause source breakage for package manifests that specify the existing `swiftLanguageVersions` parameter when updating to swift tools version 6.0
216+
The new Package `init` method and deprecating the existing `init` method will cause a deprecation warning for package manifests that specify the existing `swiftLanguageVersions` parameter when updating to swift tools version 6.0
216217
217218
A search of manifest files in public repositories suggests that about 10% of manifest files will encounter this breakage.
218219
219-
Because the obsoleted `init` method is annotated as `renamed` the compiler will automatically provide a fix-it to update to the new `init` method.
220+
Because the deprecated `init` method is annotated as `renamed` the compiler will automatically provide a fix-it to update to the new `init` method.
220221
221222
Renaming the public `swiftLanguageVersions` property of `Package` preserves backwards compatibility by introducing a computed property with that name. The computed property will be marked as `deprecated` in 6.0 and annotated as `renamed` to provide a fix-it.
222223

0 commit comments

Comments
 (0)