Skip to content

Commit 19329a4

Browse files
authored
Make ExitTestArtifacts.observedValues properly sendable. (#781)
1 parent e6abba8 commit 19329a4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct ExitTest: Sendable, ~Copyable {
3939
/// Key paths are not sendable because the properties they refer to may or may
4040
/// not be, so this property needs to be `nonisolated(unsafe)`. It is safe to
4141
/// use it in this fashion because `ExitTestArtifacts` is sendable.
42-
fileprivate nonisolated(unsafe) var _observedValues = [PartialKeyPath<ExitTestArtifacts>]()
42+
fileprivate var _observedValues = [any PartialKeyPath<ExitTestArtifacts> & Sendable]()
4343

4444
/// Key paths representing results from within this exit test that should be
4545
/// observed and returned to the caller.
@@ -56,7 +56,7 @@ public struct ExitTest: Sendable, ~Copyable {
5656
/// Within a child process running an exit test, the value of this property is
5757
/// otherwise unspecified.
5858
@_spi(ForToolsIntegrationOnly)
59-
public var observedValues: [PartialKeyPath<ExitTestArtifacts>] {
59+
public var observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable] {
6060
get {
6161
var result = _observedValues
6262
if !result.contains(\.exitCondition) { // O(n), but n <= 3 (no Set needed)
@@ -237,7 +237,7 @@ extension ExitTest {
237237
/// convention.
238238
func callExitTest(
239239
exitsWith expectedExitCondition: ExitCondition,
240-
observing observedValues: [PartialKeyPath<ExitTestArtifacts>],
240+
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable],
241241
expression: __Expression,
242242
comments: @autoclosure () -> [Comment],
243243
isRequired: Bool,

Sources/Testing/Expectations/Expectation+Macro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public macro require<R>(
518518
@discardableResult
519519
@freestanding(expression) public macro expect(
520520
exitsWith expectedExitCondition: ExitCondition,
521-
observing observedValues: [PartialKeyPath<ExitTestArtifacts>] = [],
521+
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable] = [],
522522
_ comment: @autoclosure () -> Comment? = nil,
523523
sourceLocation: SourceLocation = #_sourceLocation,
524524
performing expression: @convention(thin) () async throws -> Void
@@ -630,7 +630,7 @@ public macro require<R>(
630630
@discardableResult
631631
@freestanding(expression) public macro require(
632632
exitsWith expectedExitCondition: ExitCondition,
633-
observing observedValues: [PartialKeyPath<ExitTestArtifacts>] = [],
633+
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable] = [],
634634
_ comment: @autoclosure () -> Comment? = nil,
635635
sourceLocation: SourceLocation = #_sourceLocation,
636636
performing expression: @convention(thin) () async throws -> Void

Sources/Testing/Expectations/ExpectationChecking+Macro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ public func __checkClosureCall<R>(
11421142
@_spi(Experimental)
11431143
public func __checkClosureCall(
11441144
exitsWith expectedExitCondition: ExitCondition,
1145-
observing observedValues: [PartialKeyPath<ExitTestArtifacts>],
1145+
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable],
11461146
performing body: @convention(thin) () -> Void,
11471147
expression: __Expression,
11481148
comments: @autoclosure () -> [Comment],

0 commit comments

Comments
 (0)