@@ -163,8 +163,9 @@ extension __ExpectationContext {
163
163
///
164
164
/// This function helps overloads of `callAsFunction(_:_:)` disambiguate
165
165
/// themselves and avoid accidental recursion.
166
- private mutating func _captureValue< T> ( _ value: T , _ id: __ExpressionID ) -> T {
167
- self ( value, id)
166
+ @usableFromInline mutating func captureValue< T> ( _ value: T , _ id: __ExpressionID ) -> T {
167
+ runtimeValues [ id] = { Expression . Value ( reflecting: value) }
168
+ return value
168
169
}
169
170
170
171
/// Capture information about a value for use if the expectation currently
@@ -179,9 +180,8 @@ extension __ExpectationContext {
179
180
///
180
181
/// - Warning: This function is used to implement the `#expect()` and
181
182
/// `#require()` macros. Do not call it directly.
182
- public mutating func callAsFunction< T> ( _ value: T , _ id: __ExpressionID ) -> T {
183
- runtimeValues [ id] = { Expression . Value ( reflecting: value) }
184
- return value
183
+ @inlinable public mutating func callAsFunction< T> ( _ value: T , _ id: __ExpressionID ) -> T {
184
+ captureValue ( value, id)
185
185
}
186
186
187
187
#if SWT_SUPPORTS_MOVE_ONLY_EXPRESSION_EXPANSION
@@ -287,15 +287,15 @@ extension __ExpectationContext {
287
287
///
288
288
/// - Warning: This function is used to implement the `#expect()` and
289
289
/// `#require()` macros. Do not call it directly.
290
- public mutating func __cmp< T, U, R> (
290
+ @ inlinable public mutating func __cmp< T, U, R> (
291
291
_ op: ( T , U ) throws -> R ,
292
292
_ opID: __ExpressionID ,
293
293
_ lhs: T ,
294
294
_ lhsID: __ExpressionID ,
295
295
_ rhs: U ,
296
296
_ rhsID: __ExpressionID
297
297
) rethrows -> R {
298
- try self ( op ( self ( lhs, lhsID) , self ( rhs, rhsID) ) , opID)
298
+ try captureValue ( op ( captureValue ( lhs, lhsID) , captureValue ( rhs, rhsID) ) , opID)
299
299
}
300
300
301
301
/// Compare two bidirectional collections using `==` or `!=`.
@@ -313,7 +313,7 @@ extension __ExpectationContext {
313
313
_ rhs: C ,
314
314
_ rhsID: __ExpressionID
315
315
) -> Bool where C: BidirectionalCollection , C. Element: Equatable {
316
- let result = self ( op ( self ( lhs, lhsID) , self ( rhs, rhsID) ) , opID)
316
+ let result = captureValue ( op ( captureValue ( lhs, lhsID) , captureValue ( rhs, rhsID) ) , opID)
317
317
318
318
if !result {
319
319
differences [ opID] = { [ lhs, rhs] in
@@ -332,15 +332,15 @@ extension __ExpectationContext {
332
332
///
333
333
/// - Warning: This function is used to implement the `#expect()` and
334
334
/// `#require()` macros. Do not call it directly.
335
- public mutating func __cmp< R> (
335
+ @ inlinable public mutating func __cmp< R> (
336
336
_ op: ( R , R ) -> Bool ,
337
337
_ opID: __ExpressionID ,
338
338
_ lhs: R ,
339
339
_ lhsID: __ExpressionID ,
340
340
_ rhs: R ,
341
341
_ rhsID: __ExpressionID
342
342
) -> Bool where R: RangeExpression & BidirectionalCollection , R. Element: Equatable {
343
- self ( op ( self ( lhs, lhsID) , self ( rhs, rhsID) ) , opID)
343
+ captureValue ( op ( captureValue ( lhs, lhsID) , captureValue ( rhs, rhsID) ) , opID)
344
344
}
345
345
346
346
/// Compare two strings using `==` or `!=`.
@@ -359,7 +359,7 @@ extension __ExpectationContext {
359
359
_ rhs: S ,
360
360
_ rhsID: __ExpressionID
361
361
) -> Bool where S: StringProtocol {
362
- let result = self ( op ( self ( lhs, lhsID) , self ( rhs, rhsID) ) , opID)
362
+ let result = captureValue ( op ( captureValue ( lhs, lhsID) , captureValue ( rhs, rhsID) ) , opID)
363
363
364
364
if !result {
365
365
differences [ opID] = { [ lhs, rhs] in
@@ -409,12 +409,12 @@ extension __ExpectationContext {
409
409
///
410
410
/// - Warning: This function is used to implement the `#expect()` and
411
411
/// `#require()` macros. Do not call it directly.
412
- public mutating func __as< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> U ? {
413
- let result = self ( value, valueID) as? U
412
+ @ inlinable public mutating func __as< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> U ? {
413
+ let result = captureValue ( value, valueID) as? U
414
414
415
415
if result == nil {
416
416
let correctType = Swift . type ( of: value as Any )
417
- _ = self ( correctType, typeID)
417
+ _ = captureValue ( correctType, typeID)
418
418
}
419
419
420
420
return result
@@ -438,12 +438,12 @@ extension __ExpectationContext {
438
438
///
439
439
/// - Warning: This function is used to implement the `#expect()` and
440
440
/// `#require()` macros. Do not call it directly.
441
- public mutating func __is< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> Bool {
442
- let result = self ( value, valueID) is U
441
+ @ inlinable public mutating func __is< T, U> ( _ value: T , _ valueID: __ExpressionID , _ type: U . Type , _ typeID: __ExpressionID ) -> Bool {
442
+ let result = captureValue ( value, valueID) is U
443
443
444
444
if !result {
445
445
let correctType = Swift . type ( of: value as Any )
446
- _ = self ( correctType, typeID)
446
+ _ = captureValue ( correctType, typeID)
447
447
}
448
448
449
449
return result
@@ -468,8 +468,8 @@ extension __ExpectationContext {
468
468
///
469
469
/// - Warning: This function is used to implement the `#expect()` and
470
470
/// `#require()` macros. Do not call it directly.
471
- public mutating func callAsFunction< P1, P2> ( _ value: P1 ? , _ id: __ExpressionID ) -> P2 ! where P1: _Pointer , P2: _Pointer {
472
- _captureValue ( value, id) . flatMap { value in
471
+ @ inlinable public mutating func callAsFunction< P1, P2> ( _ value: P1 ? , _ id: __ExpressionID ) -> P2 ! where P1: _Pointer , P2: _Pointer {
472
+ captureValue ( value, id) . flatMap { value in
473
473
P2 ( bitPattern: Int ( bitPattern: value) )
474
474
}
475
475
}
@@ -493,8 +493,8 @@ extension __ExpectationContext {
493
493
///
494
494
/// - Warning: This function is used to implement the `#expect()` and
495
495
/// `#require()` macros. Do not call it directly.
496
- public mutating func callAsFunction( _ value: String , _ id: __ExpressionID ) -> String {
497
- _captureValue ( value, id)
496
+ @ inlinable public mutating func callAsFunction( _ value: String , _ id: __ExpressionID ) -> String {
497
+ captureValue ( value, id)
498
498
}
499
499
500
500
/// Capture information about a value for use if the expectation currently
@@ -512,8 +512,8 @@ extension __ExpectationContext {
512
512
///
513
513
/// - Warning: This function is used to implement the `#expect()` and
514
514
/// `#require()` macros. Do not call it directly.
515
- public mutating func callAsFunction( _ value: String , _ id: __ExpressionID ) -> String ? {
516
- _captureValue ( value, id)
515
+ @ inlinable public mutating func callAsFunction( _ value: String , _ id: __ExpressionID ) -> String ? {
516
+ captureValue ( value, id)
517
517
}
518
518
519
519
/// Capture information about a value for use if the expectation currently
@@ -531,7 +531,7 @@ extension __ExpectationContext {
531
531
///
532
532
/// - Warning: This function is used to implement the `#expect()` and
533
533
/// `#require()` macros. Do not call it directly.
534
- public mutating func callAsFunction( _ value: String ? , _ id: __ExpressionID ) -> String ? {
535
- _captureValue ( value, id)
534
+ @ inlinable public mutating func callAsFunction( _ value: String ? , _ id: __ExpressionID ) -> String ? {
535
+ captureValue ( value, id)
536
536
}
537
537
}
0 commit comments