@@ -163,8 +163,9 @@ extension __ExpectationContext {
163163 ///
164164 /// This function helps overloads of `callAsFunction(_:_:)` disambiguate
165165 /// 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
168169 }
169170
170171 /// Capture information about a value for use if the expectation currently
@@ -179,9 +180,8 @@ extension __ExpectationContext {
179180 ///
180181 /// - Warning: This function is used to implement the `#expect()` and
181182 /// `#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)
185185 }
186186
187187#if SWT_SUPPORTS_MOVE_ONLY_EXPRESSION_EXPANSION
@@ -287,15 +287,15 @@ extension __ExpectationContext {
287287 ///
288288 /// - Warning: This function is used to implement the `#expect()` and
289289 /// `#require()` macros. Do not call it directly.
290- public mutating func __cmp< T, U, R> (
290+ @ inlinable public mutating func __cmp< T, U, R> (
291291 _ op: ( T , U ) throws -> R ,
292292 _ opID: __ExpressionID ,
293293 _ lhs: T ,
294294 _ lhsID: __ExpressionID ,
295295 _ rhs: U ,
296296 _ rhsID: __ExpressionID
297297 ) rethrows -> R {
298- try self ( op ( self ( lhs, lhsID) , self ( rhs, rhsID) ) , opID)
298+ try captureValue ( op ( captureValue ( lhs, lhsID) , captureValue ( rhs, rhsID) ) , opID)
299299 }
300300
301301 /// Compare two bidirectional collections using `==` or `!=`.
@@ -313,7 +313,7 @@ extension __ExpectationContext {
313313 _ rhs: C ,
314314 _ rhsID: __ExpressionID
315315 ) -> 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)
317317
318318 if !result {
319319 differences [ opID] = { [ lhs, rhs] in
@@ -332,15 +332,15 @@ extension __ExpectationContext {
332332 ///
333333 /// - Warning: This function is used to implement the `#expect()` and
334334 /// `#require()` macros. Do not call it directly.
335- public mutating func __cmp< R> (
335+ @ inlinable public mutating func __cmp< R> (
336336 _ op: ( R , R ) -> Bool ,
337337 _ opID: __ExpressionID ,
338338 _ lhs: R ,
339339 _ lhsID: __ExpressionID ,
340340 _ rhs: R ,
341341 _ rhsID: __ExpressionID
342342 ) -> 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)
344344 }
345345
346346 /// Compare two strings using `==` or `!=`.
@@ -359,7 +359,7 @@ extension __ExpectationContext {
359359 _ rhs: S ,
360360 _ rhsID: __ExpressionID
361361 ) -> 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)
363363
364364 if !result {
365365 differences [ opID] = { [ lhs, rhs] in
@@ -409,12 +409,12 @@ extension __ExpectationContext {
409409 ///
410410 /// - Warning: This function is used to implement the `#expect()` and
411411 /// `#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
414414
415415 if result == nil {
416416 let correctType = Swift . type ( of: value as Any )
417- _ = self ( correctType, typeID)
417+ _ = captureValue ( correctType, typeID)
418418 }
419419
420420 return result
@@ -438,12 +438,12 @@ extension __ExpectationContext {
438438 ///
439439 /// - Warning: This function is used to implement the `#expect()` and
440440 /// `#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
443443
444444 if !result {
445445 let correctType = Swift . type ( of: value as Any )
446- _ = self ( correctType, typeID)
446+ _ = captureValue ( correctType, typeID)
447447 }
448448
449449 return result
@@ -468,8 +468,8 @@ extension __ExpectationContext {
468468 ///
469469 /// - Warning: This function is used to implement the `#expect()` and
470470 /// `#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
473473 P2 ( bitPattern: Int ( bitPattern: value) )
474474 }
475475 }
@@ -493,8 +493,8 @@ extension __ExpectationContext {
493493 ///
494494 /// - Warning: This function is used to implement the `#expect()` and
495495 /// `#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)
498498 }
499499
500500 /// Capture information about a value for use if the expectation currently
@@ -512,8 +512,8 @@ extension __ExpectationContext {
512512 ///
513513 /// - Warning: This function is used to implement the `#expect()` and
514514 /// `#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)
517517 }
518518
519519 /// Capture information about a value for use if the expectation currently
@@ -531,7 +531,7 @@ extension __ExpectationContext {
531531 ///
532532 /// - Warning: This function is used to implement the `#expect()` and
533533 /// `#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)
536536 }
537537}
0 commit comments