Skip to content

Commit 8f04a33

Browse files
authored
Update Swift tools version to 5.9 (#861)
* Update Swift tools version to 5.9 rdar://116871051 * Use if-let shorthand (SE-0345) available from Swift 5.7 * Modernize generics with opaque types (SE-0328 & SE-0341) available from Swift 5.7 This also leverages "primary associated types" (SE-0358) available from Swift 5.7 * Remove unused AnyCommunicationBridge type-erasure wrapper * Remove back-port of pointer API (SE-0370) available in Swift 5.8 * Use package access level (SE-0386, available from Swift 5.9) instead of SPI for FileManagerProtocol * Simplify extensions using bound generic types (SE-0361) available since Swift 5.7 * Use shorthand syntax for array, dictionary, and optional types (always available) * Define primary associated type (SE-0346) for DirectiveArgument protocol * Use opaque parameter types (SE-0341) in protocol definitions * Use opaque return types (SE-0328) for some properties * Use array and dictionary shorthand syntax in more places * Use bound generic types (SE-0361) for extensions in more places * Revert "Use package access level (SE-0386, available from Swift 5.9) instead of SPI for FileManagerProtocol" f1ca44c
1 parent 135a55e commit 8f04a33

File tree

174 files changed

+435
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+435
-524
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# This source file is part of the Swift.org open source project
22
#
3-
# Copyright (c) 2021 Apple Inc. and the Swift project authors
3+
# Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
44
# Licensed under Apache License v2.0 with Runtime Library Exception
55
#
66
# See https://swift.org/LICENSE.txt for license information
77
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
FROM swift:5.5
9+
FROM swift:5.9-focal
1010

1111
# Set up the current build user in the same way done in the Swift.org CI system:
1212
# https://github.com/apple/swift-docker/blob/main/swift-ci/master/ubuntu/20.04/Dockerfile.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// swift-tools-version:5.6
1+
// swift-tools-version:5.9
22
/*
33
This source file is part of the Swift.org open source project
44

5-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
5+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
66
Licensed under Apache License v2.0 with Runtime Library Exception
77

88
See https://swift.org/LICENSE.txt for license information

Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public struct GeneratedCurationWriter {
7878
// Calculate the longest link to nicely align all the comments
7979
let longestLink = links.map(\.link.count).max()! // `links` are non-empty so it's safe to force-unwrap `.max()` here
8080
for (link, comment) in links {
81-
if let comment = comment {
81+
if let comment {
8282
text.append(link.padding(toLength: longestLink, withPad: " ", startingAt: 0))
8383
text.append(comment)
8484
} else {
@@ -127,7 +127,7 @@ public struct GeneratedCurationWriter {
127127
return [:]
128128
}
129129

130-
if let symbolLink = symbolLink {
130+
if let symbolLink {
131131
switch context.linkResolver.resolve(UnresolvedTopicReference(topicURL: .init(symbolPath: symbolLink)), in: curationCrawlRoot, fromSymbolLink: true, context: context) {
132132
case .success(let foundSymbol):
133133
curationCrawlRoot = foundSymbol
@@ -146,7 +146,7 @@ public struct GeneratedCurationWriter {
146146
}
147147

148148
guard let absoluteLink = allAbsoluteLinks[usr], let curationText = defaultCurationText(for: reference) else { continue }
149-
if let catalogURL = catalogURL, let existingURL = context.documentationExtensionURL(for: reference) {
149+
if let catalogURL, let existingURL = context.documentationExtensionURL(for: reference) {
150150
let updatedFileURL: URL
151151
if catalogURL == outputURL {
152152
updatedFileURL = existingURL

Sources/SwiftDocC/Checker/Checker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public struct AnyChecker: Checker {
181181
private var box: AnyCheckerBox
182182

183183
/// Creates an instance that type erases the given checker.
184-
public init<C: Checker>(_ checker: C) {
184+
public init(_ checker: some Checker) {
185185
self.box = CheckerBox(checker)
186186
}
187187

@@ -270,7 +270,7 @@ public struct CompositeChecker: Checker {
270270
public var checkers: [AnyChecker]
271271

272272
/// Creates a checker that performs the combined work of the given checkers.
273-
public init<Checkers: Sequence>(_ checkers: Checkers) where Checkers.Element: Checker {
273+
public init(_ checkers: some Sequence<Checker>) {
274274
self.checkers = checkers.map { $0.any() }
275275
}
276276

Sources/SwiftDocC/Checker/Checkers/DuplicateTopicsSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct DuplicateTopicsSections: Checker {
3535
return duplicates.map { duplicateHeading -> Problem in
3636
let range = duplicateHeading.range!
3737
let notes: [DiagnosticNote]
38-
if let sourceFile = sourceFile, let range = first.range {
38+
if let sourceFile, let range = first.range {
3939
notes = [DiagnosticNote(source: sourceFile, range: range, message: "First Topics Section starts here.")]
4040
} else {
4141
notes = []

Sources/SwiftDocC/Checker/Checkers/NonInclusiveLanguageChecker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public struct NonInclusiveLanguageChecker: Checker {
110110
explanation: term.message
111111
)
112112
var solutions: [Solution] = []
113-
if let range = range {
113+
if let range {
114114
let replacement = Replacement(range: range, replacement: term.replacement)
115115
let solution = Solution(summary: "Replace with \(term.replacement.singleQuoted)", replacements: [replacement])
116116
solutions.append(solution)

Sources/SwiftDocC/Checker/Checkers/NonOverviewHeadingChecker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct NonOverviewHeadingChecker: Checker {
2222
return nonOverviewHeadings.compactMap { heading -> Problem? in
2323
guard let headingRange = heading.range else { return nil }
2424
let notes: [DiagnosticNote]
25-
if let sourceFile = sourceFile, let range = overviewHeading?.range {
25+
if let sourceFile, let range = overviewHeading?.range {
2626
notes = [DiagnosticNote(source: sourceFile, range: range, message: "Overview section starts here")]
2727
} else {
2828
notes = []

Sources/SwiftDocC/Converter/RenderNode+Coding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public extension RenderNode {
213213
do {
214214
// If there is no topic reference cache, just encode the reference.
215215
// To skim a little off the duration we first do a quick check if the key is present at all.
216-
guard let renderReferenceCache = renderReferenceCache else {
216+
guard let renderReferenceCache else {
217217
return try encoder.encode(self)
218218
}
219219

Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ enum TopicRenderReferenceEncoder {
9494

9595
// If a cache key was provided, update the cache with the reference and it's
9696
// overrides.
97-
if let cacheKey = cacheKey {
97+
if let cacheKey {
9898
referenceCache.sync { cache in
9999
cache[cacheKey] = (
100100
encodedReference,

Sources/SwiftDocC/Coverage/DocumentationCoverageOptions.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ extension DocumentationCoverageOptions {
139139
}
140140

141141
extension DocumentationCoverageOptions.KindFilterOptions {
142-
public init<List>(bitFlags: List) where
143-
List: Collection,
144-
List.Element == BitFlagRepresentation {
142+
public init(bitFlags: some Collection<BitFlagRepresentation>) {
145143
let mask = bitFlags.reduce(0) {
146144
$0 | $1.bitMask
147145
}

0 commit comments

Comments
 (0)