You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
12
12
13
13
## 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.
15
15
16
16
### Terminology
17
17
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
49
49
- The parameter `swiftLanguageVersions` is renamed to `swiftLanguageModes`
50
50
- The parameter type is now an optional array of `SwiftLanguageMode` values instead of `SwiftVersion` values
51
51
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.
53
53
54
54
#### 2. Rename `swiftLanguageVersions` property to `swiftLanguageModes`
55
55
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
104
104
### Swift Package Manager
105
105
Proposed Swift Package Manager API changes are limited to manifests \>=6.0:
106
106
107
-
### New Package init method and obsoletedinit method
107
+
### New Package init method and deprecatedinit method
108
108
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:
109
109
110
110
```swift
@@ -123,10 +123,11 @@ Package(
123
123
```
124
124
125
125
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:
The existing method must be obsoleted because the two methods are ambiguous when the default value for `swiftLanguageVersions` / `swiftLanguageModes` is used:
144
-
145
-
```
146
-
Package ( // Error: Ambiguous use of 'init'
147
-
name: "MyPackage",
148
-
products: ...,
149
-
targets: ...
150
-
)
151
-
```
152
-
153
-
This follows the same approach used by all past revisions of the Package `init` method.
154
-
155
143
See the **Source compatibility** section for more details about this change.
156
144
157
145
### Rename `swiftLanguageVersions` property to `swiftLanguageModes`
@@ -212,11 +200,11 @@ public struct SwiftSetting {
212
200
```
213
201
214
202
## 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
203
+
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
216
204
217
205
A search of manifest files in public repositories suggests that about 10% of manifest files will encounter this breakage.
218
206
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.
207
+
Because the deprecated `init` method is annotated as `renamed` the compiler will automatically provide a fix-it to update to the new `init` method.
220
208
221
209
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.
0 commit comments