You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove some uses of @unchecked Sendable and AnySequence.
This PR removes some outstanding uses of `@unchecked Sendable` and of
`AnySequence`.
Ironically we still need `Test.testCases` to type-erase with `AnySequence` _in
its implementation only_ for now because if we change it from
`some Sequence<Test.Case>` to `any Sequence<Test.Case>` we get this diagnostic:
> 🛑 Runtime support for parameterized protocol types is only available in macOS
> 13.0.0 or newer
/// An enumeration describing the evaluation state of a test's cases.
72
-
///
73
-
/// This use of `@unchecked Sendable` and of `AnySequence` in this type's
74
-
/// cases is necessary because it is not currently possible to express
75
-
/// `Sequence<Test.Case> & Sendable` as an existential (`any`)
76
-
/// ([96960993](rdar://96960993)). It is also not possible to have a value of
77
-
/// an underlying generic sequence type without specifying its generic
78
-
/// parameters.
79
-
fileprivateenumTestCasesState:@uncheckedSendable{
72
+
fileprivateenumTestCasesState:Sendable{
80
73
/// The test's cases have not yet been evaluated.
81
74
///
82
75
/// - Parameters:
83
76
/// - function: The function to call to evaluate the test's cases. The
84
77
/// result is a sequence of test cases.
85
-
case unevaluated(_ function:@Sendable()asyncthrows->AnySequence<Test.Case>)
78
+
case unevaluated(_ function:@Sendable()asyncthrows->anySequence<Test.Case>&Sendable)
86
79
87
80
/// The test's cases have been evaluated.
88
81
///
89
82
/// - Parameters:
90
83
/// - testCases: The test's cases.
91
-
case evaluated(_ testCases:AnySequence<Test.Case>)
84
+
case evaluated(_ testCases:anySequence<Test.Case>&Sendable)
92
85
93
86
/// An error was thrown when the testing library attempted to evaluate the
94
87
/// test's cases.
@@ -124,7 +117,7 @@ public struct Test: Sendable {
124
117
// attempt to run it, and thus never access this property.
125
118
preconditionFailure("Attempting to access test cases with invalid state. Please file a bug report at https://github.com/swiftlang/swift-testing/issues/new and include this information: \(String(reflecting: testCasesState))")
126
119
}
127
-
return testCases
120
+
returnAnySequence(testCases)
128
121
}
129
122
}
130
123
@@ -139,7 +132,7 @@ public struct Test: Sendable {
139
132
varuncheckedTestCases:(someSequence<Test.Case>)?{
140
133
testCasesState.flatMap{ testCasesState in
141
134
if case let.evaluated(testCases)= testCasesState {
142
-
return testCases
135
+
returnAnySequence(testCases)
143
136
}
144
137
returnnil
145
138
}
@@ -239,7 +232,7 @@ public struct Test: Sendable {
0 commit comments