Skip to content

Commit ca4c4d8

Browse files
dylanmarykMatty Cross
authored andcommitted
Fix errors when using Swift 6 strict concurrency checking
1 parent 4379da2 commit ca4c4d8

File tree

13 files changed

+142
-35
lines changed

13 files changed

+142
-35
lines changed

.package.resolved

Lines changed: 121 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,123 @@
11
{
2-
"object": {
3-
"pins": [
4-
{
5-
"package": "OCMock",
6-
"repositoryURL": "https://github.com/erikdoe/ocmock.git",
7-
"state": {
8-
"branch": null,
9-
"revision": "2c0bfd373289f4a7716db5d6db471640f91a6507",
10-
"version": null
11-
}
12-
}
13-
]
14-
},
15-
"version": 1
2+
"originHash" : "a64ff5917cc2a5d0406bc10508197e31aa8e7eaacbc9e999a52bea35093394de",
3+
"pins" : [
4+
{
5+
"identity" : "aexml",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/tadija/AEXML.git",
8+
"state" : {
9+
"revision" : "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",
10+
"version" : "4.6.1"
11+
}
12+
},
13+
{
14+
"identity" : "filekit",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/nvzqz/FileKit.git",
17+
"state" : {
18+
"revision" : "9006d2888025fbe893c3c396327b2fe45a8c177b",
19+
"version" : "6.1.0"
20+
}
21+
},
22+
{
23+
"identity" : "pathkit",
24+
"kind" : "remoteSourceControl",
25+
"location" : "https://github.com/kylef/PathKit.git",
26+
"state" : {
27+
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
28+
"version" : "1.0.1"
29+
}
30+
},
31+
{
32+
"identity" : "rainbow",
33+
"kind" : "remoteSourceControl",
34+
"location" : "https://github.com/onevcat/Rainbow",
35+
"state" : {
36+
"revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",
37+
"version" : "4.0.1"
38+
}
39+
},
40+
{
41+
"identity" : "spectre",
42+
"kind" : "remoteSourceControl",
43+
"location" : "https://github.com/kylef/Spectre.git",
44+
"state" : {
45+
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
46+
"version" : "0.10.1"
47+
}
48+
},
49+
{
50+
"identity" : "stencil",
51+
"kind" : "remoteSourceControl",
52+
"location" : "https://github.com/kylef/Stencil.git",
53+
"state" : {
54+
"revision" : "4f222ac85d673f35df29962fc4c36ccfdaf9da5b",
55+
"version" : "0.15.1"
56+
}
57+
},
58+
{
59+
"identity" : "swift-argument-parser",
60+
"kind" : "remoteSourceControl",
61+
"location" : "https://github.com/apple/swift-argument-parser",
62+
"state" : {
63+
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
64+
"version" : "1.2.3"
65+
}
66+
},
67+
{
68+
"identity" : "swift-cmark",
69+
"kind" : "remoteSourceControl",
70+
"location" : "https://github.com/apple/swift-cmark.git",
71+
"state" : {
72+
"revision" : "f218e5d7691f78b55bfa39b367763f4612486c35",
73+
"version" : "0.3.0"
74+
}
75+
},
76+
{
77+
"identity" : "swift-format",
78+
"kind" : "remoteSourceControl",
79+
"location" : "https://github.com/apple/swift-format.git",
80+
"state" : {
81+
"revision" : "83248b4fa37919f78ffbd4650946759bcc54c2b5",
82+
"version" : "509.0.0"
83+
}
84+
},
85+
{
86+
"identity" : "swift-markdown",
87+
"kind" : "remoteSourceControl",
88+
"location" : "https://github.com/apple/swift-markdown.git",
89+
"state" : {
90+
"revision" : "e4f95e2dc23097a1a9a1dfdfe3fe3ee44de77378",
91+
"version" : "0.3.0"
92+
}
93+
},
94+
{
95+
"identity" : "swift-syntax",
96+
"kind" : "remoteSourceControl",
97+
"location" : "https://github.com/apple/swift-syntax.git",
98+
"state" : {
99+
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
100+
"version" : "509.0.0"
101+
}
102+
},
103+
{
104+
"identity" : "tomlkit",
105+
"kind" : "remoteSourceControl",
106+
"location" : "https://github.com/LebJe/TOMLKit.git",
107+
"state" : {
108+
"revision" : "404c4dd011743461bff12d00a5118d0ed59d630c",
109+
"version" : "0.5.5"
110+
}
111+
},
112+
{
113+
"identity" : "xcodeproj",
114+
"kind" : "remoteSourceControl",
115+
"location" : "https://github.com/tuist/XcodeProj.git",
116+
"state" : {
117+
"revision" : "3797181813ee963fe305d939232bc576d23ddbb0",
118+
"version" : "8.15.0"
119+
}
120+
}
121+
],
122+
"version" : 3
16123
}

Cuckoo.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.watchos.deployment_target = '8.0'
1818
s.tvos.deployment_target = '13.0'
1919
generator_name = 'cuckoonator'
20-
s.swift_version = '5.0'
20+
s.swift_version = '6.0'
2121
s.preserve_paths = ['Generator/**/*', 'version', 'run', 'build_generator', generator_name]
2222
s.prepare_command = <<-CMD
2323
curl -Lo #{generator_name} https://github.com/Brightify/Cuckoo/releases/download/#{s.version}/#{generator_name}

Generator/Sources/CLI/GenerateCommand.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Foundation
22
import ArgumentParser
33
import TOMLKit
4-
import FileKit
4+
@preconcurrency import FileKit
55

66
@main
77
@available(macOS 12, *)
88
struct GenerateCommand: AsyncParsableCommand {
9-
static var configuration = CommandConfiguration(
9+
nonisolated(unsafe) static var configuration = CommandConfiguration(
1010
commandName: "Generate",
1111
abstract: "Cuckoo CLI tool for generating mocks according to the specified configuration.",
1212
version: version,

Generator/Sources/CLI/Generator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import FileKit
2+
@preconcurrency import FileKit
33
import XcodeProj
44
import Rainbow
55

Generator/Sources/CLI/Glob.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class Glob: Collection {
2626
let includesFilesInResultsIfTrailingSlash: Bool
2727
}
2828

29-
static var defaultBehavior = Glob.Behavior(
29+
static let defaultBehavior = Glob.Behavior(
3030
supportsGlobstar: true,
3131
includesFilesFromRootOfGlobstar: true,
3232
includesDirectoriesInResults: false,

Generator/Sources/CLI/Logger.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ final class Logger {
77
case error
88
}
99

10-
static let shared = Logger()
10+
nonisolated(unsafe) static let shared = Logger()
1111

1212
var logLevel: LogLevel = .info
1313

Generator/Sources/CLI/Module.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Foundation
22
import FileKit
33

4-
final class Module {
5-
static var overriddenOutput: String?
4+
final class Module: @unchecked Sendable {
5+
nonisolated(unsafe) static var overriddenOutput: String?
66

77
let name: String
88
let imports: [String]

Generator/Sources/Internal/Helpers/Async+convenience.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ extension Sequence {
4040
}
4141
}
4242

43-
extension Sequence {
43+
extension Sequence where Element: Sendable {
4444
func concurrentForEach(
45-
_ operation: @escaping (Element) async -> Void
45+
_ operation: @escaping @Sendable (Element) async -> Void
4646
) async {
4747
// A task group automatically waits for all of its
4848
// sub-tasks to complete, while also performing those
@@ -67,9 +67,9 @@ extension Sequence {
6767
}
6868
}
6969

70-
extension Sequence {
71-
func concurrentMap<T>(
72-
_ transform: @escaping (Element) async throws -> T
70+
extension Sequence where Element: Sendable {
71+
func concurrentMap<T: Sendable>(
72+
_ transform: @escaping @Sendable (Element) async throws -> T
7373
) async rethrows -> [T] {
7474
let tasks = map { element in
7575
Task {
@@ -82,8 +82,8 @@ extension Sequence {
8282
}
8383
}
8484

85-
func concurrentCompactMap<T>(
86-
_ transform: @escaping (Element) async throws -> T?
85+
func concurrentCompactMap<T: Sendable>(
86+
_ transform: @escaping @Sendable (Element) async throws -> T?
8787
) async rethrows -> [T] {
8888
let tasks = map { element in
8989
Task {

Generator/Sources/Internal/Tokens/FileRepresentation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import FileKit
33

4-
struct FileRepresentation {
4+
struct FileRepresentation: @unchecked Sendable {
55
let file: TextFile
66
let imports: [Import]
77
let tokens: [Token]

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

0 commit comments

Comments
 (0)