Skip to content

Commit 5535a95

Browse files
authored
Fix some Swift 5.6 compatibility issues (#516)
* Use existential CodingKey parameters consistently Swift 5.7 supports implicit opening for existentials, so these conversions from `CodingKey` parameters to pass to methods that are generic over `CodingKey` work fine. Prior to Swift 5.7, however, these don't compile, with the message that `CodingKey` doesn't conform to itself. * Bump the required Swift version for the count-lines test The overload resolution for the `static func main()` in an `@main` type still had issues in Swift 5.6, such that a package with a min. platform below that which works for concurrency backdeployment doesn't properly resolve the AsyncParsableCommand `main()` function. In Swift 5.7, this is properly resolved, so just the availability on the main type is sufficient. This change just skips the test of `count-lines` prior to Swift 5.7, so that we can maintain the open platform minimum for the package as a whole.
1 parent 4256f88 commit 5535a95

File tree

4 files changed

+4
-19
lines changed

4 files changed

+4
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.vscode
77
.*.sw?
88
*.docc-build
9+
*.vs

Package.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,3 @@ var package = Package(
6868
resources: [.copy("CountLinesTest.txt")]),
6969
]
7070
)
71-
72-
#if swift(>=5.6) && os(macOS)
73-
package.targets.append(contentsOf: [
74-
// Examples
75-
.executableTarget(
76-
name: "count-lines",
77-
dependencies: ["ArgumentParser"],
78-
path: "Examples/count-lines"),
79-
80-
// Tools
81-
.executableTarget(
82-
name: "changelog-authors",
83-
dependencies: ["ArgumentParser"],
84-
path: "Tools/changelog-authors"),
85-
])
86-
#endif

Sources/ArgumentParser/Parsing/InputKey.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct InputKey: Hashable {
7272
/// - Parameter codingKey: The base ``CodingKey``
7373
/// - Parameter path: The list of ``CodingKey`` values that lead to this one. May be empty.
7474
@inlinable
75-
init<C: CodingKey>(codingKey: C, path: [CodingKey]) {
75+
init(codingKey: CodingKey, path: [CodingKey]) {
7676
self.init(name: codingKey.stringValue, parent: Parent(InputKey(path: path)))
7777
}
7878

@@ -113,7 +113,7 @@ extension InputKey {
113113
///
114114
/// - Parameter codingKey: The key to clean.
115115
/// - Returns: The cleaned key.
116-
static func clean<C: CodingKey>(codingKey: C) -> String {
116+
static func clean(codingKey: CodingKey) -> String {
117117
clean(codingKey: codingKey.stringValue)
118118
}
119119
}

Tests/ArgumentParserExampleTests/CountLinesExampleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
#if os(macOS) && swift(>=5.6)
12+
#if os(macOS) && swift(>=5.7)
1313

1414
import XCTest
1515
import ArgumentParserTestHelpers

0 commit comments

Comments
 (0)