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

done compatible with Sendable #1159

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Sources/Nimble/DSL+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
file: FileString = #filePath,
line: UInt = #line,
column: UInt = #column,
action: @escaping (@escaping () -> Void) async -> Void
action: @escaping (@escaping @Sendable () -> Void) async -> Void
) async {
await throwableUntil(
timeout: timeout,
Expand All @@ -116,7 +116,7 @@
file: FileString = #filePath,
line: UInt = #line,
column: UInt = #column,
action: @escaping (@escaping () -> Void) -> Void
action: @escaping (@escaping @Sendable () -> Void) -> Void
) async {
await throwableUntil(
timeout: timeout,
Expand All @@ -134,12 +134,12 @@
private func throwableUntil(
timeout: NimbleTimeInterval,
sourceLocation: SourceLocation,
action: @escaping (@escaping () -> Void) async throws -> Void) async {
action: @escaping (@escaping @Sendable () -> Void) async throws -> Void) async {
let leeway = timeout.divided
let result = await performBlock(
timeoutInterval: timeout,
leeway: leeway,
sourceLocation: sourceLocation) { @MainActor (done: @escaping (ErrorResult) -> Void) async throws -> Void in

Check warning on line 142 in Sources/Nimble/DSL+AsyncAwait.swift

View workflow job for this annotation

GitHub Actions / lint

Redundant Void Return Violation: Returning Void in a function declaration is redundant (redundant_void_return)
do {
try await action {
done(.none)
Expand Down
9 changes: 9 additions & 0 deletions Tests/NimbleTests/AsyncAwaitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ final class AsyncAwaitTest: XCTestCase { // swiftlint:disable:this type_body_len
}
}

func testWaitUntilUsingSendable() async {
await waitUntil { done in
let queue = OperationQueue()
let op = BlockOperation {}
op.completionBlock = done
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • On Swift5:
    • Before
      • Warning: Assigning non-sendable parameter 'done' to a @Sendable closure
    • After
      • No-Warning

queue.addOperation(op)
}
}

func testWaitUntilTimesOutIfNotCalled() async {
await failsWithErrorMessage("Waited more than 1.0 second") {
await waitUntil(timeout: .seconds(1)) { _ in return }
Expand Down
Loading