Skip to content

Commit e1f07fa

Browse files
authored
Fix some warnings (#3279)
We have a few warnings, mostly in the test suite, that have cropped up with deprecations and Xcode 16 strict concurrency, so let's address them.
1 parent 8541597 commit e1f07fa

File tree

12 files changed

+107
-78
lines changed

12 files changed

+107
-78
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

+10-10
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@
6868
"kind" : "remoteSourceControl",
6969
"location" : "https://github.com/pointfreeco/swift-custom-dump",
7070
"state" : {
71-
"revision" : "aec6a73f5c1dc1f1be4f61888094b95cf995d973",
72-
"version" : "1.3.2"
71+
"revision" : "82645ec760917961cfa08c9c0c7104a57a0fa4b1",
72+
"version" : "1.3.3"
7373
}
7474
},
7575
{
7676
"identity" : "swift-dependencies",
7777
"kind" : "remoteSourceControl",
7878
"location" : "https://github.com/pointfreeco/swift-dependencies",
7979
"state" : {
80-
"revision" : "cc26d06125dbc913c6d9e8a905a5db0b994509e0",
81-
"version" : "1.3.5"
80+
"revision" : "d7472be6b3c89251ce4c0db07d32405b43426781",
81+
"version" : "1.3.7"
8282
}
8383
},
8484
{
@@ -113,8 +113,8 @@
113113
"kind" : "remoteSourceControl",
114114
"location" : "https://github.com/pointfreeco/swift-macro-testing",
115115
"state" : {
116-
"revision" : "a35257b7e9ce44e92636447003a8eeefb77b145c",
117-
"version" : "0.5.1"
116+
"revision" : "20c1a8f3b624fb5d1503eadcaa84743050c350f4",
117+
"version" : "0.5.2"
118118
}
119119
},
120120
{
@@ -131,17 +131,17 @@
131131
"kind" : "remoteSourceControl",
132132
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
133133
"state" : {
134-
"revision" : "c097f955b4e724690f0fc8ffb7a6d4b881c9c4e3",
135-
"version" : "1.17.2"
134+
"revision" : "6d932a79e7173b275b96c600c86c603cf84f153c",
135+
"version" : "1.17.4"
136136
}
137137
},
138138
{
139139
"identity" : "swift-syntax",
140140
"kind" : "remoteSourceControl",
141141
"location" : "https://github.com/swiftlang/swift-syntax",
142142
"state" : {
143-
"revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c",
144-
"version" : "600.0.0-prerelease-2024-06-12"
143+
"revision" : "06b5cdc432e93b60e3bdf53aff2857c6b312991a",
144+
"version" : "600.0.0-prerelease-2024-07-30"
145145
}
146146
},
147147
{

Examples/SyncUps/SyncUpsTests/SyncUpFormTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class SyncUpFormTests: XCTestCase {
2020
$0.uuid = .incrementing
2121
}
2222

23-
XCTAssertNoDifference(
23+
expectNoDifference(
2424
store.state.syncUp.attendees,
2525
[
2626
Attendee(id: Attendee.ID(UUID(0)))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Foundation
2+
3+
extension MainActor {
4+
// NB: This functionality was not back-deployed in Swift 5.9
5+
static func _assumeIsolated<T : Sendable>(
6+
_ operation: @MainActor () throws -> T,
7+
file: StaticString = #fileID,
8+
line: UInt = #line
9+
) rethrows -> T {
10+
#if swift(<5.10)
11+
typealias YesActor = @MainActor () throws -> T
12+
typealias NoActor = () throws -> T
13+
14+
guard Thread.isMainThread else {
15+
fatalError(
16+
"Incorrect actor executor assumption; Expected same executor as \(self).",
17+
file: file,
18+
line: line
19+
)
20+
}
21+
22+
return try withoutActuallyEscaping(operation) { (_ fn: @escaping YesActor) throws -> T in
23+
let rawFn = unsafeBitCast(fn, to: NoActor.self)
24+
return try rawFn()
25+
}
26+
#else
27+
return try assumeIsolated(operation, file: file, line: line)
28+
#endif
29+
}
30+
}

Sources/ComposableArchitecture/Internal/DispatchQueue.swift

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Dispatch
22

33
func mainActorASAP(execute block: @escaping @MainActor @Sendable () -> Void) {
44
if DispatchQueue.getSpecific(key: key) == value {
5-
assumeMainActorIsolated {
5+
MainActor._assumeIsolated {
66
block()
77
}
88
} else {
@@ -18,10 +18,3 @@ private let key: DispatchSpecificKey<UInt8> = {
1818
return key
1919
}()
2020
private let value: UInt8 = 0
21-
22-
// NB: Currently we can't use 'MainActor.assumeIsolated' on CI, but we can approximate this in
23-
// the meantime.
24-
@MainActor(unsafe)
25-
private func assumeMainActorIsolated(_ block: @escaping @MainActor @Sendable () -> Void) {
26-
block()
27-
}

Sources/ComposableArchitecture/SharedState/Shared.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,14 @@ public struct Shared<Value> {
218218
}
219219
try updateValueToExpectedResult(&snapshot)
220220
self.snapshot = snapshot
221-
// TODO: Finesse error more than `XCTAssertNoDifference`
222-
XCTAssertNoDifference(
221+
// TODO: Finesse error more than `expectNoDifference`
222+
expectNoDifference(
223223
self.currentValue,
224224
self.snapshot,
225-
file: filePath,
226-
line: line
225+
fileID: fileID,
226+
filePath: filePath,
227+
line: line,
228+
column: column
227229
)
228230
self.snapshot = nil
229231
}

Tests/ComposableArchitectureTests/DebugTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898
store.send(true)
9999
try await Task.sleep(nanoseconds: 300_000_000)
100-
XCTAssertNoDifference(
100+
expectNoDifference(
101101
logs.value,
102102
"""
103103
- true
@@ -129,7 +129,7 @@
129129
store.send(true)
130130
store.send(false)
131131
_ = XCTWaiter.wait(for: [self.expectation(description: "wait")], timeout: 0.3)
132-
XCTAssertNoDifference(
132+
expectNoDifference(
133133
logs.value,
134134
"""
135135
- true
@@ -177,7 +177,7 @@
177177
}
178178
store.send(true)
179179
try await Task.sleep(nanoseconds: 300_000_000)
180-
XCTAssertNoDifference(
180+
expectNoDifference(
181181
logs.value,
182182
#"""
183183
DebugTests.State(

0 commit comments

Comments
 (0)