Skip to content

Commit 8e54501

Browse files
committed
Add Swift 5.10 support
1 parent 2d1fe95 commit 8e54501

File tree

5 files changed

+83
-16
lines changed

5 files changed

+83
-16
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-generate-and-publish-docs.yml@main
2121
with:
2222
os: ubuntu
23-
swift-version: '5.9'
23+
swift-version: '5.10'
2424
organisation: ${{ github.repository_owner }}
2525
repository: ${{ github.event.repository.name }}
2626
pages-branch: gh-pages

.github/workflows/swift-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212
jobs:
1313
variables:
1414
outputs:
15-
max-supported-swift-version: '5.9'
15+
max-supported-swift-version: '5.10'
1616
xcode-scheme: route-docs
1717
xcode-platform-version: latest
1818
fail-if-codecov-fails: true
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
os: [ macOS, ubuntu ]
28-
swift-version-offset: [ 0 ]
28+
swift-version-offset: [ 0, 1 ]
2929
uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-spm.yml@main
3030
with:
3131
os: ${{ matrix.os }}
@@ -45,7 +45,8 @@ jobs:
4545
# - iPadOS
4646
# - tvOS
4747
# - watchOS
48-
swift-version-offset: [ 0 ]
48+
# - visionOS
49+
swift-version-offset: [ 0, 1 ]
4950
uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-xcode.yml@main
5051
with:
5152
xcode-scheme: ${{ needs.variables.outputs.xcode-scheme }}

Package.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:5.10
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -8,9 +8,12 @@ let swiftSettings: Array<SwiftSetting> = [
88
.enableUpcomingFeature("ExistentialAny"),
99
.enableUpcomingFeature("BareSlashRegexLiterals"),
1010
.enableUpcomingFeature("DisableOutwardActorInference"),
11+
.enableUpcomingFeature("IsolatedDefaultValues"),
12+
.enableUpcomingFeature("DeprecateApplicationMain"),
13+
.enableExperimentalFeature("StrictConcurrency"),
14+
.enableExperimentalFeature("GlobalConcurrency"),
1115
// .enableExperimentalFeature("AccessLevelOnImport"),
1216
// .enableExperimentalFeature("VariadicGenerics"),
13-
// .unsafeFlags(["-warn-concurrency"], .when(configuration: .debug)),
1417
]
1518

1619
let package = Package(
@@ -27,8 +30,8 @@ let package = Package(
2730
dependencies: [
2831
// Dependencies declare other packages that this package depends on.
2932
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
30-
.package(url: "https://github.com/apple/swift-nio", from: "2.59.0"),
31-
.package(url: "https://github.com/vapor/vapor", from: "4.84.0"),
33+
.package(url: "https://github.com/apple/swift-nio", from: "2.64.0"),
34+
.package(url: "https://github.com/vapor/vapor", from: "4.92.0"),
3235
.package(url: "https://github.com/vapor/leaf-kit", from: "1.10.0"),
3336
.package(url: "https://github.com/vapor/leaf", from: "4.2.0"),
3437
],

Package@swift-5.9.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// swift-tools-version:5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let swiftSettings: Array<SwiftSetting> = [
7+
.enableUpcomingFeature("ConciseMagicFile"),
8+
.enableUpcomingFeature("ExistentialAny"),
9+
.enableUpcomingFeature("BareSlashRegexLiterals"),
10+
.enableUpcomingFeature("DisableOutwardActorInference"),
11+
.enableExperimentalFeature("StrictConcurrency"),
12+
// .enableExperimentalFeature("AccessLevelOnImport"),
13+
// .enableExperimentalFeature("VariadicGenerics"),
14+
]
15+
16+
let package = Package(
17+
name: "route-docs",
18+
platforms: [
19+
.macOS(.v10_15),
20+
],
21+
products: [
22+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
23+
.library(
24+
name: "RouteDocs",
25+
targets: ["RouteDocs"]),
26+
],
27+
dependencies: [
28+
// Dependencies declare other packages that this package depends on.
29+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
30+
.package(url: "https://github.com/apple/swift-nio", from: "2.59.0"),
31+
.package(url: "https://github.com/vapor/vapor", from: "4.84.0"),
32+
.package(url: "https://github.com/vapor/leaf-kit", from: "1.10.0"),
33+
.package(url: "https://github.com/vapor/leaf", from: "4.2.0"),
34+
],
35+
targets: [
36+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
37+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
38+
.target(
39+
name: "RouteDocs",
40+
dependencies: [
41+
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
42+
.product(name: "Vapor", package: "vapor"),
43+
.product(name: "LeafKit", package: "leaf-kit"),
44+
.product(name: "Leaf", package: "leaf"),
45+
],
46+
resources: [
47+
.copy("DefaultDocsView"),
48+
],
49+
swiftSettings: swiftSettings),
50+
.testTarget(
51+
name: "RouteDocsTests",
52+
dependencies: ["RouteDocs"],
53+
swiftSettings: swiftSettings),
54+
]
55+
)

Sources/RouteDocs/DocumentationDecoder.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public struct DocumentationObject: Sendable, Hashable, CustomStringConvertible {
5959
}
6060
}
6161

62+
public static func clearTypeCaches() {
63+
DocumentationDecoder.Cache.clear()
64+
}
65+
6266
public let type: Any.Type
6367
public fileprivate(set) var body: Body
6468

@@ -166,7 +170,7 @@ fileprivate struct DocumentationDecoder: Decoder {
166170
self.init(storage: .init(type: type), codingPath: .init(), userInfo: userInfo)
167171
}
168172

169-
func push(key: some CodingKey) -> DocumentationDecoder {
173+
func pushKey(_ key: some CodingKey) -> DocumentationDecoder {
170174
.init(storage: storage, codingPath: codingPath + CollectionOfOne<any CodingKey>(key), userInfo: userInfo)
171175
}
172176

@@ -201,7 +205,7 @@ fileprivate struct DocumentationDecoder: Decoder {
201205
return result
202206
}
203207
try setType(type, for: key)
204-
let result = try T(from: push(key: key))
208+
let result = try T(from: pushKey(key))
205209
try cache(result)
206210
return result
207211
}
@@ -283,7 +287,7 @@ extension DocumentationDecoder {
283287
}
284288

285289
fileprivate enum Cache {
286-
struct Entry {
290+
struct Entry: @unchecked Sendable {
287291
let object: any Decodable
288292
let documentation: DocumentationObject
289293
}
@@ -298,6 +302,10 @@ extension DocumentationDecoder {
298302
// We must use the doc's type here, otherwise we mix up optionals vs. non-optionals.
299303
storage.withLockedValue { $0[ObjectIdentifier(entry.documentation.type)] = entry }
300304
}
305+
306+
static func clear() {
307+
storage.withLockedValue { $0.removeAll() }
308+
}
301309
}
302310

303311
fileprivate final class TypeBuilder {
@@ -445,15 +453,15 @@ extension DocumentationDecoder {
445453
func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer<NestedKey>
446454
where NestedKey: CodingKey
447455
{
448-
KeyedDecodingContainer(KeyedContainer<NestedKey>(decoder: decoder.push(key: key)))
456+
KeyedDecodingContainer(KeyedContainer<NestedKey>(decoder: decoder.pushKey(key)))
449457
}
450458

451459
func nestedUnkeyedContainer(forKey key: Key) throws -> any UnkeyedDecodingContainer {
452-
UnkeyedContainer(decoder: decoder.push(key: key))
460+
UnkeyedContainer(decoder: decoder.pushKey(key))
453461
}
454462

455463
func superDecoder() throws -> any Decoder { decoder }
456-
func superDecoder(forKey key: Key) throws -> any Decoder { decoder.push(key: key) }
464+
func superDecoder(forKey key: Key) throws -> any Decoder { decoder.pushKey(key) }
457465
}
458466

459467
fileprivate struct UnkeyedContainer: UnkeyedDecodingContainer {
@@ -595,12 +603,12 @@ extension DocumentationDecoder {
595603
where NestedKey: CodingKey
596604
{
597605
defer { currentIndex += 1 }
598-
return KeyedDecodingContainer(KeyedContainer(decoder: decoder.push(key: IndexKey(index: currentIndex))))
606+
return KeyedDecodingContainer(KeyedContainer(decoder: decoder.pushKey(IndexKey(index: currentIndex))))
599607
}
600608

601609
mutating func nestedUnkeyedContainer() throws -> any UnkeyedDecodingContainer {
602610
defer { currentIndex += 1 }
603-
return UnkeyedContainer(decoder: decoder.push(key: IndexKey(index: currentIndex)))
611+
return UnkeyedContainer(decoder: decoder.pushKey(IndexKey(index: currentIndex)))
604612
}
605613

606614
mutating func superDecoder() throws -> any Decoder { decoder }

0 commit comments

Comments
 (0)