@@ -450,8 +450,8 @@ extension __ExpectationContext {
450450 /// - Warning: This function is used to implement the `#expect()` and
451451 /// `#require()` macros. Do not call it directly.
452452 @_disfavoredOverload
453- public mutating func callAsFunction< PFrom , PTo > ( _ value: PFrom , _ id: __ExpressionID ) -> PTo where PFrom : _Pointer , PTo : _Pointer {
454- self ( value as PFrom ? , id) as! PTo
453+ public mutating func callAsFunction< P , T > ( _ value: P , _ id: __ExpressionID ) -> UnsafePointer < T > where P : _Pointer , P . Pointee == T {
454+ self ( value as P ? , id) !
455455 }
456456
457457 /// Convert some pointer to an immutable one and capture information about it
@@ -470,9 +470,51 @@ extension __ExpectationContext {
470470 /// - Warning: This function is used to implement the `#expect()` and
471471 /// `#require()` macros. Do not call it directly.
472472 @_disfavoredOverload
473- public mutating func callAsFunction< PFrom , PTo > ( _ value: PFrom ? , _ id: __ExpressionID ) -> PTo ? where PFrom : _Pointer , PTo : _Pointer {
473+ public mutating func callAsFunction< P , T > ( _ value: P ? , _ id: __ExpressionID ) -> UnsafePointer < T > ? where P : _Pointer , P . Pointee == T {
474474 value. flatMap { value in
475- PTo ( bitPattern: Int ( bitPattern: self ( value, id) as PFrom ) )
475+ UnsafePointer < T > ( bitPattern: Int ( bitPattern: self ( value, id) as P ) )
476+ }
477+ }
478+
479+ /// Convert some pointer to an immutable one and capture information about it
480+ /// for use if the expectation currently being evaluated fails.
481+ ///
482+ /// - Parameters:
483+ /// - value: The pointer to make immutable.
484+ /// - id: A value that uniquely identifies the represented expression in the
485+ /// context of the expectation currently being evaluated.
486+ ///
487+ /// - Returns: `value`, cast to an immutable pointer.
488+ ///
489+ /// This overload of `callAsFunction(_:_:)` handles the implicit conversions
490+ /// between various pointer types that are normally provided by the compiler.
491+ ///
492+ /// - Warning: This function is used to implement the `#expect()` and
493+ /// `#require()` macros. Do not call it directly.
494+ @_disfavoredOverload
495+ public mutating func callAsFunction< P> ( _ value: P , _ id: __ExpressionID ) -> UnsafeRawPointer where P: _Pointer {
496+ self ( value as P ? , id) !
497+ }
498+
499+ /// Convert some pointer to an immutable one and capture information about it
500+ /// for use if the expectation currently being evaluated fails.
501+ ///
502+ /// - Parameters:
503+ /// - value: The pointer to make immutable.
504+ /// - id: A value that uniquely identifies the represented expression in the
505+ /// context of the expectation currently being evaluated.
506+ ///
507+ /// - Returns: `value`, cast to an immutable pointer.
508+ ///
509+ /// This overload of `callAsFunction(_:_:)` handles the implicit conversions
510+ /// between various pointer types that are normally provided by the compiler.
511+ ///
512+ /// - Warning: This function is used to implement the `#expect()` and
513+ /// `#require()` macros. Do not call it directly.
514+ @_disfavoredOverload
515+ public mutating func callAsFunction< P> ( _ value: P ? , _ id: __ExpressionID ) -> UnsafeRawPointer ? where P: _Pointer {
516+ value. flatMap { value in
517+ UnsafeRawPointer ( bitPattern: Int ( bitPattern: self ( value, id) as P ) )
476518 }
477519 }
478520}
0 commit comments