@@ -450,8 +450,8 @@ extension __ExpectationContext {
450
450
/// - Warning: This function is used to implement the `#expect()` and
451
451
/// `#require()` macros. Do not call it directly.
452
452
@_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) !
455
455
}
456
456
457
457
/// Convert some pointer to an immutable one and capture information about it
@@ -470,9 +470,51 @@ extension __ExpectationContext {
470
470
/// - Warning: This function is used to implement the `#expect()` and
471
471
/// `#require()` macros. Do not call it directly.
472
472
@_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 {
474
474
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 ) )
476
518
}
477
519
}
478
520
}
0 commit comments