Skip to content

Commit def883e

Browse files
committed
Remove usage of the swift 6 only sending keyword (#1168)
1 parent 12c1c0c commit def883e

File tree

11 files changed

+60
-60
lines changed

11 files changed

+60
-60
lines changed

Sources/Nimble/Adapters/NMBExpectation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ private func from(objcMatcher: NMBMatcher) -> Matcher<NSObject> {
1414

1515
// Equivalent to Expectation, but for Nimble's Objective-C interface
1616
public final class NMBExpectation: NSObject, Sendable {
17-
internal let _actualBlock: @Sendable () -> sending NSObject?
17+
internal let _actualBlock: @Sendable () -> NSObject?
1818
internal let _negative: Bool
1919
internal let _file: FileString
2020
internal let _line: UInt
2121
internal let _timeout: NimbleTimeInterval
2222

23-
@objc public init(actualBlock: @escaping @Sendable () -> sending NSObject?, negative: Bool, file: FileString, line: UInt) {
23+
@objc public init(actualBlock: @escaping @Sendable () -> NSObject?, negative: Bool, file: FileString, line: UInt) {
2424
self._actualBlock = actualBlock
2525
self._negative = negative
2626
self._file = file
2727
self._line = line
2828
self._timeout = .seconds(1)
2929
}
3030

31-
private init(actualBlock: @escaping @Sendable () -> sending NSObject?, negative: Bool, file: FileString, line: UInt, timeout: NimbleTimeInterval) {
31+
private init(actualBlock: @escaping @Sendable () -> NSObject?, negative: Bool, file: FileString, line: UInt, timeout: NimbleTimeInterval) {
3232
self._actualBlock = actualBlock
3333
self._negative = negative
3434
self._file = file

Sources/Nimble/AsyncExpression.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private final class MemoizedClosure<T: Sendable>: Sendable {
6767
// Memoizes the given closure, only calling the passed
6868
// closure once; even if repeat calls to the returned closure
6969
private func memoizedClosure<T: Sendable>(
70-
_ closure: sending @escaping @Sendable () async throws -> T
70+
_ closure: @escaping @Sendable () async throws -> T
7171
) -> @Sendable (Bool) async throws -> T {
7272
let memoized = MemoizedClosure(closure)
7373
return memoized.callAsFunction(_:)
@@ -85,7 +85,7 @@ private func memoizedClosure<T: Sendable>(
8585
/// This provides a common consumable API for matchers to utilize to allow
8686
/// Nimble to change internals to how the captured closure is managed.
8787
public actor AsyncExpression<Value: Sendable> {
88-
internal let _expression: @Sendable (Bool) async throws -> sending Value?
88+
internal let _expression: @Sendable (Bool) async throws -> Value?
8989
internal let _withoutCaching: Bool
9090
public let location: SourceLocation
9191
public let isClosure: Bool
@@ -101,7 +101,7 @@ public actor AsyncExpression<Value: Sendable> {
101101
/// requires an explicit closure. This gives Nimble
102102
/// flexibility if @autoclosure behavior changes between
103103
/// Swift versions. Nimble internals always sets this true.
104-
public init(expression: sending @escaping @Sendable () async throws -> sending Value?, location: SourceLocation, isClosure: Bool = true) {
104+
public init(expression: @escaping @Sendable () async throws -> Value?, location: SourceLocation, isClosure: Bool = true) {
105105
self._expression = memoizedClosure(expression)
106106
self.location = location
107107
self._withoutCaching = false
@@ -122,7 +122,7 @@ public actor AsyncExpression<Value: Sendable> {
122122
/// requires an explicit closure. This gives Nimble
123123
/// flexibility if @autoclosure behavior changes between
124124
/// Swift versions. Nimble internals always sets this true.
125-
public init(memoizedExpression: @escaping @Sendable (Bool) async throws -> sending Value?, location: SourceLocation, withoutCaching: Bool, isClosure: Bool = true) {
125+
public init(memoizedExpression: @escaping @Sendable (Bool) async throws -> Value?, location: SourceLocation, withoutCaching: Bool, isClosure: Bool = true) {
126126
self._expression = memoizedExpression
127127
self.location = location
128128
self._withoutCaching = withoutCaching
@@ -153,23 +153,23 @@ public actor AsyncExpression<Value: Sendable> {
153153
///
154154
/// - Parameter block: The block that can cast the current Expression value to a
155155
/// new type.
156-
public func cast<U>(_ block: @escaping @Sendable (Value?) throws -> sending U?) -> AsyncExpression<U> {
156+
public func cast<U>(_ block: @escaping @Sendable (Value?) throws -> U?) -> AsyncExpression<U> {
157157
AsyncExpression<U>(
158158
expression: ({ try await block(self.evaluate()) }),
159159
location: self.location,
160160
isClosure: self.isClosure
161161
)
162162
}
163163

164-
public func cast<U>(_ block: @escaping @Sendable (Value?) async throws -> sending U?) -> AsyncExpression<U> {
164+
public func cast<U>(_ block: @escaping @Sendable (Value?) async throws -> U?) -> AsyncExpression<U> {
165165
AsyncExpression<U>(
166166
expression: ({ try await block(self.evaluate()) }),
167167
location: self.location,
168168
isClosure: self.isClosure
169169
)
170170
}
171171

172-
public func evaluate() async throws -> sending Value? {
172+
public func evaluate() async throws -> Value? {
173173
try await self._expression(_withoutCaching)
174174
}
175175

Sources/Nimble/DSL+AsyncAwait.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Dispatch
33
#endif
44

55
/// Make an ``AsyncExpectation`` on a given actual value. The value given is lazily evaluated.
6-
public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @escaping @Sendable () async throws -> sending T?) -> AsyncExpectation<T> {
6+
public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @escaping @Sendable () async throws -> T?) -> AsyncExpectation<T> {
77
return AsyncExpectation(
88
expression: AsyncExpression(
99
expression: expression,
@@ -12,7 +12,7 @@ public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #fi
1212
}
1313

1414
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
15-
public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @Sendable () -> (@Sendable () async throws -> sending T)) -> AsyncExpectation<T> {
15+
public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @Sendable () -> (@Sendable () async throws -> T)) -> AsyncExpectation<T> {
1616
return AsyncExpectation(
1717
expression: AsyncExpression(
1818
expression: expression(),
@@ -21,7 +21,7 @@ public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #fi
2121
}
2222

2323
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
24-
public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @Sendable () -> (@Sendable () async throws -> sending T?)) -> AsyncExpectation<T> {
24+
public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @Sendable () -> (@Sendable () async throws -> T?)) -> AsyncExpectation<T> {
2525
return AsyncExpectation(
2626
expression: AsyncExpression(
2727
expression: expression(),
@@ -30,7 +30,7 @@ public func expect<T: Sendable>(fileID: String = #fileID, file: FileString = #fi
3030
}
3131

3232
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
33-
public func expect(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @Sendable () -> (@Sendable () async throws -> sending Void)) -> AsyncExpectation<Void> {
33+
public func expect(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @Sendable () -> (@Sendable () async throws -> Void)) -> AsyncExpectation<Void> {
3434
return AsyncExpectation(
3535
expression: AsyncExpression(
3636
expression: expression(),
@@ -40,7 +40,7 @@ public func expect(fileID: String = #fileID, file: FileString = #filePath, line:
4040

4141
/// Make an ``AsyncExpectation`` on a given actual value. The value given is lazily evaluated.
4242
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`.
43-
public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @escaping @Sendable () async throws -> sending T?) async -> AsyncExpectation<T> {
43+
public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @escaping @Sendable () async throws -> T?) async -> AsyncExpectation<T> {
4444
return AsyncExpectation(
4545
expression: AsyncExpression(
4646
expression: expression,
@@ -50,7 +50,7 @@ public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #f
5050

5151
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
5252
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`
53-
public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @Sendable () -> (@Sendable () async throws -> sending T)) async -> AsyncExpectation<T> {
53+
public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @Sendable () -> (@Sendable () async throws -> T)) async -> AsyncExpectation<T> {
5454
return AsyncExpectation(
5555
expression: AsyncExpression(
5656
expression: expression(),
@@ -60,7 +60,7 @@ public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #f
6060

6161
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
6262
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`
63-
public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @Sendable () -> (@Sendable () async throws -> sending T?)) async -> AsyncExpectation<T> {
63+
public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @Sendable () -> (@Sendable () async throws -> T?)) async -> AsyncExpectation<T> {
6464
return AsyncExpectation(
6565
expression: AsyncExpression(
6666
expression: expression(),
@@ -70,7 +70,7 @@ public func expecta<T: Sendable>(fileID: String = #fileID, file: FileString = #f
7070

7171
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
7272
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`
73-
public func expecta(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @Sendable () -> (@Sendable () async throws -> sending Void)) async -> AsyncExpectation<Void> {
73+
public func expecta(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column, _ expression: @autoclosure @Sendable () -> (@Sendable () async throws -> Void)) async -> AsyncExpectation<Void> {
7474
return AsyncExpectation(
7575
expression: AsyncExpression(
7676
expression: expression(),

0 commit comments

Comments
 (0)