18
18
///
19
19
/// - Warning: This type is used to implement the `#expect()` and `#require()`
20
20
/// macros. Do not use it directly.
21
- public struct __ExpectationContext : ~ Copyable {
21
+ public final class __ExpectationContext {
22
22
/// The source code representations of any captured expressions.
23
23
///
24
24
/// Unlike the rest of the state in this type, the source code dictionary is
@@ -167,7 +167,7 @@ extension __ExpectationContext {
167
167
///
168
168
/// This function helps overloads of `callAsFunction(_:_:)` disambiguate
169
169
/// themselves and avoid accidental recursion.
170
- @usableFromInline mutating func captureValue< T> ( _ value: T , _ id: __ExpressionID ) -> T {
170
+ @usableFromInline func captureValue< T> ( _ value: T , _ id: __ExpressionID ) -> T {
171
171
runtimeValues [ id] = { Expression . Value ( reflecting: value) }
172
172
return value
173
173
}
@@ -185,7 +185,7 @@ extension __ExpectationContext {
185
185
/// - Warning: This function is used to implement the `#expect()` and
186
186
/// `#require()` macros. Do not call it directly.
187
187
@_disfavoredOverload
188
- @inlinable public mutating func callAsFunction< T> ( _ value: T , _ id: __ExpressionID ) -> T {
188
+ @inlinable public func callAsFunction< T> ( _ value: T , _ id: __ExpressionID ) -> T {
189
189
captureValue ( value, id)
190
190
}
191
191
@@ -203,7 +203,7 @@ extension __ExpectationContext {
203
203
/// - Warning: This function is used to implement the `#expect()` and
204
204
/// `#require()` macros. Do not call it directly.
205
205
@_disfavoredOverload
206
- public mutating func callAsFunction< T> ( _ value: consuming T , _ id: __ExpressionID ) -> T where T: ~ Copyable {
206
+ public func callAsFunction< T> ( _ value: consuming T , _ id: __ExpressionID ) -> T where T: ~ Copyable {
207
207
// TODO: add support for borrowing non-copyable expressions (need @lifetime)
208
208
return value
209
209
}
@@ -219,7 +219,7 @@ extension __ExpectationContext {
219
219
///
220
220
/// - Warning: This function is used to implement the `#expect()` and
221
221
/// `#require()` macros. Do not call it directly.
222
- public mutating func __inoutAfter< T> ( _ value: T , _ id: __ExpressionID ) {
222
+ public func __inoutAfter< T> ( _ value: T , _ id: __ExpressionID ) {
223
223
runtimeValues [ id] = { Expression . Value ( reflecting: value, timing: . after) }
224
224
}
225
225
}
@@ -272,14 +272,14 @@ extension __ExpectationContext {
272
272
///
273
273
/// - Warning: This function is used to implement the `#expect()` and
274
274
/// `#require()` macros. Do not call it directly.
275
- @inlinable public mutating func __cmp< T, U, R > (
276
- _ op: ( T , U ) throws -> R ,
275
+ @inlinable public func __cmp< T, U> (
276
+ _ op: ( T , U ) throws -> Bool ,
277
277
_ opID: __ExpressionID ,
278
278
_ lhs: T ,
279
279
_ lhsID: __ExpressionID ,
280
280
_ rhs: U ,
281
281
_ rhsID: __ExpressionID
282
- ) rethrows -> R {
282
+ ) rethrows -> Bool {
283
283
try captureValue ( op ( captureValue ( lhs, lhsID) , captureValue ( rhs, rhsID) ) , opID)
284
284
}
285
285
@@ -290,7 +290,7 @@ extension __ExpectationContext {
290
290
///
291
291
/// - Warning: This function is used to implement the `#expect()` and
292
292
/// `#require()` macros. Do not call it directly.
293
- public mutating func __cmp< C> (
293
+ public func __cmp< C> (
294
294
_ op: ( C , C ) -> Bool ,
295
295
_ opID: __ExpressionID ,
296
296
_ lhs: C ,
@@ -315,7 +315,7 @@ extension __ExpectationContext {
315
315
///
316
316
/// - Warning: This function is used to implement the `#expect()` and
317
317
/// `#require()` macros. Do not call it directly.
318
- @inlinable public mutating func __cmp< R> (
318
+ @inlinable public func __cmp< R> (
319
319
_ op: ( R , R ) -> Bool ,
320
320
_ opID: __ExpressionID ,
321
321
_ lhs: R ,
@@ -334,7 +334,7 @@ extension __ExpectationContext {
334
334
///
335
335
/// - Warning: This function is used to implement the `#expect()` and
336
336
/// `#require()` macros. Do not call it directly.
337
- public mutating func __cmp< S> (
337
+ public func __cmp< S> (
338
338
_ op: ( S , S ) -> Bool ,
339
339
_ opID: __ExpressionID ,
340
340
_ lhs: S ,
@@ -392,7 +392,7 @@ extension __ExpectationContext {
392
392
///
393
393
/// - Warning: This function is used to implement the `#expect()` and
394
394
/// `#require()` macros. Do not call it directly.
395
- @inlinable public mutating func __as< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> U ? {
395
+ @inlinable public func __as< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> U ? {
396
396
let result = captureValue ( value, valueID) as? U
397
397
398
398
if result == nil {
@@ -421,7 +421,7 @@ extension __ExpectationContext {
421
421
///
422
422
/// - Warning: This function is used to implement the `#expect()` and
423
423
/// `#require()` macros. Do not call it directly.
424
- @inlinable public mutating func __is< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> Bool {
424
+ @inlinable public func __is< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> Bool {
425
425
let result = captureValue ( value, valueID) is U
426
426
427
427
if !result {
0 commit comments