Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings #3279

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -68,17 +68,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "aec6a73f5c1dc1f1be4f61888094b95cf995d973",
"version" : "1.3.2"
"revision" : "82645ec760917961cfa08c9c0c7104a57a0fa4b1",
"version" : "1.3.3"
}
},
{
"identity" : "swift-dependencies",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-dependencies",
"state" : {
"revision" : "cc26d06125dbc913c6d9e8a905a5db0b994509e0",
"version" : "1.3.5"
"revision" : "d7472be6b3c89251ce4c0db07d32405b43426781",
"version" : "1.3.7"
}
},
{
@@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-macro-testing",
"state" : {
"revision" : "a35257b7e9ce44e92636447003a8eeefb77b145c",
"version" : "0.5.1"
"revision" : "20c1a8f3b624fb5d1503eadcaa84743050c350f4",
"version" : "0.5.2"
}
},
{
@@ -131,17 +131,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "c097f955b4e724690f0fc8ffb7a6d4b881c9c4e3",
"version" : "1.17.2"
"revision" : "6d932a79e7173b275b96c600c86c603cf84f153c",
"version" : "1.17.4"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c",
"version" : "600.0.0-prerelease-2024-06-12"
"revision" : "06b5cdc432e93b60e3bdf53aff2857c6b312991a",
"version" : "600.0.0-prerelease-2024-07-30"
}
},
{
2 changes: 1 addition & 1 deletion Examples/SyncUps/SyncUpsTests/SyncUpFormTests.swift
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ final class SyncUpFormTests: XCTestCase {
$0.uuid = .incrementing
}

XCTAssertNoDifference(
expectNoDifference(
store.state.syncUp.attendees,
[
Attendee(id: Attendee.ID(UUID(0)))
30 changes: 30 additions & 0 deletions Sources/ComposableArchitecture/Internal/AssumeIsolated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Foundation

extension MainActor {
// NB: This functionality was not back-deployed in Swift 5.9
static func _assumeIsolated<T : Sendable>(
_ operation: @MainActor () throws -> T,
file: StaticString = #fileID,
line: UInt = #line
) rethrows -> T {
#if swift(<5.10)
typealias YesActor = @MainActor () throws -> T
typealias NoActor = () throws -> T

guard Thread.isMainThread else {
fatalError(
"Incorrect actor executor assumption; Expected same executor as \(self).",
file: file,
line: line
)
}

return try withoutActuallyEscaping(operation) { (_ fn: @escaping YesActor) throws -> T in
let rawFn = unsafeBitCast(fn, to: NoActor.self)
return try rawFn()
}
#else
return try assumeIsolated(operation, file: file, line: line)
#endif
}
}
9 changes: 1 addition & 8 deletions Sources/ComposableArchitecture/Internal/DispatchQueue.swift
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import Dispatch

func mainActorASAP(execute block: @escaping @MainActor @Sendable () -> Void) {
if DispatchQueue.getSpecific(key: key) == value {
assumeMainActorIsolated {
MainActor._assumeIsolated {
block()
}
} else {
@@ -18,10 +18,3 @@ private let key: DispatchSpecificKey<UInt8> = {
return key
}()
private let value: UInt8 = 0

// NB: Currently we can't use 'MainActor.assumeIsolated' on CI, but we can approximate this in
// the meantime.
@MainActor(unsafe)
private func assumeMainActorIsolated(_ block: @escaping @MainActor @Sendable () -> Void) {
block()
}
10 changes: 6 additions & 4 deletions Sources/ComposableArchitecture/SharedState/Shared.swift
Original file line number Diff line number Diff line change
@@ -218,12 +218,14 @@ public struct Shared<Value> {
}
try updateValueToExpectedResult(&snapshot)
self.snapshot = snapshot
// TODO: Finesse error more than `XCTAssertNoDifference`
XCTAssertNoDifference(
// TODO: Finesse error more than `expectNoDifference`
expectNoDifference(
self.currentValue,
self.snapshot,
file: filePath,
line: line
fileID: fileID,
filePath: filePath,
line: line,
column: column
)
self.snapshot = nil
}
6 changes: 3 additions & 3 deletions Tests/ComposableArchitectureTests/DebugTests.swift
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@
}
store.send(true)
try await Task.sleep(nanoseconds: 300_000_000)
XCTAssertNoDifference(
expectNoDifference(
logs.value,
"""
- true
@@ -129,7 +129,7 @@
store.send(true)
store.send(false)
_ = XCTWaiter.wait(for: [self.expectation(description: "wait")], timeout: 0.3)
XCTAssertNoDifference(
expectNoDifference(
logs.value,
"""
- true
@@ -177,7 +177,7 @@
}
store.send(true)
try await Task.sleep(nanoseconds: 300_000_000)
XCTAssertNoDifference(
expectNoDifference(
logs.value,
#"""
DebugTests.State(
Loading