Skip to content

Commit e1f56f1

Browse files
authored
Enable SE-0335 (Existential any) upcoming feature (#1181)
1 parent 57511c7 commit e1f56f1

File tree

230 files changed

+736
-735
lines changed

Some content is hidden

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

230 files changed

+736
-735
lines changed

Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import class Foundation.ProcessInfo
1414

1515
let swiftSettings: [SwiftSetting] = [
1616
.unsafeFlags(["-Xfrontend", "-warn-long-expression-type-checking=1000"], .when(configuration: .debug)),
17+
18+
.enableUpcomingFeature("ExistentialAny"), // SE-0335: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0335-existential-any.md
1719
]
1820

1921
let package = Package(

Sources/SwiftDocC/Benchmark/Benchmark.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Benchmark: Encodable {
5353
#endif
5454

5555
/// The list of metrics included in this benchmark.
56-
public var metrics: [BenchmarkMetric] = []
56+
public var metrics: [any BenchmarkMetric] = []
5757

5858
enum CodingKeys: String, CodingKey {
5959
case date, metrics, arguments, platform
@@ -71,8 +71,8 @@ public class Benchmark: Encodable {
7171
guard let result = log.result else {
7272
return nil
7373
}
74-
let id = (log as? DynamicallyIdentifiableMetric)?.identifier ?? type(of: log).identifier
75-
let displayName = (log as? DynamicallyIdentifiableMetric)?.displayName ?? type(of: log).displayName
74+
let id = (log as? (any DynamicallyIdentifiableMetric))?.identifier ?? type(of: log).identifier
75+
let displayName = (log as? (any DynamicallyIdentifiableMetric))?.displayName ?? type(of: log).displayName
7676
return .init(id: id, displayName: displayName, value: result)
7777
}
7878

@@ -84,13 +84,13 @@ public class Benchmark: Encodable {
8484
)
8585
}
8686

87-
public func encode(to encoder: Encoder) throws {
87+
public func encode(to encoder: any Encoder) throws {
8888
try results()?.encode(to: encoder)
8989
}
9090
}
9191

9292
private extension Benchmark {
93-
func shouldLogMetricType(_ metricType: BenchmarkMetric.Type) -> Bool {
93+
func shouldLogMetricType(_ metricType: any BenchmarkMetric.Type) -> Bool {
9494
return isEnabled && (metricsFilter == nil || metricType.identifier.hasPrefix(metricsFilter!))
9595
}
9696
}

Sources/SwiftDocC/Benchmark/BenchmarkResults.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public struct BenchmarkResults: Codable {
9797
case duration, bytesInMemory, bytesOnDisk, checksum
9898
}
9999

100-
public init(from decoder: Decoder) throws {
100+
public init(from decoder: any Decoder) throws {
101101
let container = try decoder.container(keyedBy: CodingKeys.self)
102102

103103
switch try container.decode(ValueKind.self, forKey: .type) {
@@ -112,7 +112,7 @@ public struct BenchmarkResults: Codable {
112112
}
113113
}
114114

115-
public func encode(to encoder: Encoder) throws {
115+
public func encode(to encoder: any Encoder) throws {
116116
var container = encoder.container(keyedBy: CodingKeys.self)
117117

118118
switch self {
@@ -149,7 +149,7 @@ extension BenchmarkResults {
149149
case platformName, timestamp, doccArguments, metrics
150150
}
151151

152-
public init(from decoder: Decoder) throws {
152+
public init(from decoder: any Decoder) throws {
153153
let container = try decoder.container(keyedBy: CodingKeys.self)
154154

155155
if container.contains(.platformName) {

Sources/SwiftDocC/Checker/Checker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public struct CompositeChecker: Checker {
280280
}
281281
}
282282

283-
public mutating func visit(_ markup: Markup) -> () {
283+
public mutating func visit(_ markup: any Markup) -> () {
284284
for i in checkers.indices {
285285
checkers[i].visit(markup)
286286
}

Sources/SwiftDocC/Checker/Checkers/AbstractContainsFormattedTextOnly.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct AbstractContainsFormattedTextOnly: Checker {
4343
}
4444
}
4545

46-
private mutating func foundInvalidContent(_ invalidContent: InvalidContent, markup: Markup) {
46+
private mutating func foundInvalidContent(_ invalidContent: InvalidContent, markup: any Markup) {
4747
let explanation = """
4848
Summary should only contain (formatted) text. To resolve this issue, place links and images elsewhere in the document, or remove them.
4949
"""

Sources/SwiftDocC/Checker/Checkers/NonInclusiveLanguageChecker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public struct NonInclusiveLanguageChecker: Checker {
129129
/// - markup: The markup element that contains the text.
130130
/// - Returns: An array of ranges at which the term was found.
131131
/// > Warning: Crashes if the term expression pattern is not valid.
132-
func ranges(for term: Term, in text: String, of markup: Markup) -> [SourceRange] {
132+
func ranges(for term: Term, in text: String, of markup: any Markup) -> [SourceRange] {
133133
var ranges = [SourceRange]()
134134

135135
let regex = try! defaultRegularExpressions[term.expression]

Sources/SwiftDocC/Converter/Rewriter/RenderNodeTransformationComposition.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
/// A transformation that applies two transformations, one after the other.
1212
public struct RenderNodeTransformationComposition: RenderNodeTransforming {
1313
/// The first transformation to apply.
14-
public var first: RenderNodeTransforming
14+
public var first: any RenderNodeTransforming
1515
/// The second transformation to apply.
16-
public var second: RenderNodeTransforming
16+
public var second: any RenderNodeTransforming
1717

1818
/// Initializes a transformation that applies two transformations, one after the other.
1919
///
2020
/// - Parameters:
2121
/// - first: The first transformation to apply.
2222
/// - second: The second transformation to apply.
23-
public init(first: RenderNodeTransforming, second: RenderNodeTransforming) {
23+
public init(first: any RenderNodeTransforming, second: any RenderNodeTransforming) {
2424
self.first = first
2525
self.second = second
2626
}

Sources/SwiftDocC/Converter/Rewriter/RenderNodeTransformer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ open class RenderNodeTransformer {
3737
///
3838
/// - Parameter transformation: The transformation to apply.
3939
/// - Returns: The transformed render node.
40-
public func apply(transformation: RenderNodeTransforming) -> RenderNode {
40+
public func apply(transformation: any RenderNodeTransforming) -> RenderNode {
4141
let context = RenderNodeTransformationContext(referencesCount: referencesCount)
4242

4343
return transformation

Sources/SwiftDocC/Converter/Rewriter/RenderNodeTransforming.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extension RenderNodeTransforming {
2727
///
2828
/// - Parameter otherTransformation: The other transformation to apply after the receiver.
2929
/// - Returns: A new transformation that applies the two transformations, one after another.
30-
public func then(_ otherTransformation: RenderNodeTransforming) -> RenderNodeTransformationComposition {
30+
public func then(_ otherTransformation: any RenderNodeTransforming) -> RenderNodeTransformationComposition {
3131
return RenderNodeTransformationComposition(first: self, second: otherTransformation)
3232
}
3333
}

Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ enum TopicRenderReferenceEncoder {
2323
/// instance to avoid encoding the same reference objects repeatedly.
2424
static func addRenderReferences(
2525
to renderNodeData: inout Data,
26-
references: [String: RenderReference],
26+
references: [String: any RenderReference],
2727
encodeAccumulatedVariantOverrides: Bool = false,
2828
encoder: JSONEncoder,
2929
renderReferenceCache referenceCache: RenderReferenceCache

0 commit comments

Comments
 (0)