@@ -430,8 +430,8 @@ extension __ExpectationContext {
430
430
// MARK: - Implicit pointer conversion
431
431
432
432
extension __ExpectationContext {
433
- /// Convert a mutable pointer to an immutable one and capture information
434
- /// about it for use if the expectation currently being evaluated fails.
433
+ /// Convert some pointer to an immutable one and capture information about it
434
+ /// for use if the expectation currently being evaluated fails.
435
435
///
436
436
/// - Parameters:
437
437
/// - value: The pointer to make immutable.
@@ -440,76 +440,70 @@ extension __ExpectationContext {
440
440
///
441
441
/// - Returns: `value`, cast to an immutable pointer.
442
442
///
443
- /// This overload of `callAsFunction(_:_:)` handles the implicit conversion
444
- /// from a mutable to an immutable pointer that is normally provided by the
445
- /// compiler.
443
+ /// This overload of `callAsFunction(_:_:)` handles the implicit conversions
444
+ /// between various pointer types that are normally provided by the compiler.
446
445
///
447
446
/// - Warning: This function is used to implement the `#expect()` and
448
447
/// `#require()` macros. Do not call it directly.
449
- public mutating func callAsFunction< T> ( _ value: UnsafeMutablePointer < T > , _ id: __ExpressionID ) -> UnsafePointer < T > {
450
- UnsafePointer ( self ( value, id) as UnsafeMutablePointer < T > )
448
+ public mutating func callAsFunction< P , T> ( _ value: P , _ id: __ExpressionID ) -> UnsafePointer < T > where P : _Pointer {
449
+ self ( value as P ? , id) !
451
450
}
452
451
453
- /// Convert an optional mutable pointer to an immutable one and capture
454
- /// information about it for use if the expectation currently being evaluated
455
- /// fails.
452
+ /// Convert some pointer to an immutable one and capture information about it
453
+ /// for use if the expectation currently being evaluated fails.
456
454
///
457
455
/// - Parameters:
458
- /// - value: The pointer to make immutable, or `nil` .
456
+ /// - value: The pointer to make immutable.
459
457
/// - id: A value that uniquely identifies the represented expression in the
460
458
/// context of the expectation currently being evaluated.
461
459
///
462
460
/// - Returns: `value`, cast to an immutable pointer.
463
461
///
464
- /// This overload of `callAsFunction(_:_:)` handles the implicit conversion
465
- /// from a mutable to an immutable pointer that is normally provided by the
466
- /// compiler.
462
+ /// This overload of `callAsFunction(_:_:)` handles the implicit conversions
463
+ /// between various pointer types that are normally provided by the compiler.
467
464
///
468
465
/// - Warning: This function is used to implement the `#expect()` and
469
466
/// `#require()` macros. Do not call it directly.
470
- public mutating func callAsFunction< T> ( _ value: UnsafeMutablePointer < T > ? , _ id: __ExpressionID ) -> UnsafePointer < T > ? {
471
- UnsafePointer ( self ( value, id) as UnsafeMutablePointer < T > ? )
467
+ public mutating func callAsFunction< P , T> ( _ value: P ? , _ id: __ExpressionID ) -> UnsafePointer < T > ? where P : _Pointer {
468
+ UnsafePointer ( bitPattern : Int ( bitPattern : self ( value, id) as P ? ) )
472
469
}
473
470
474
- /// Convert a mutable raw pointer to an immutable one and capture information
475
- /// about it for use if the expectation currently being evaluated fails.
471
+ /// Convert some pointer to an immutable one and capture information about it
472
+ /// for use if the expectation currently being evaluated fails.
476
473
///
477
474
/// - Parameters:
478
475
/// - value: The pointer to make immutable.
479
476
/// - id: A value that uniquely identifies the represented expression in the
480
477
/// context of the expectation currently being evaluated.
481
478
///
482
- /// - Returns: `value`, cast to an immutable raw pointer.
479
+ /// - Returns: `value`, cast to an immutable pointer.
483
480
///
484
- /// This overload of `callAsFunction(_:_:)` handles the implicit conversion
485
- /// from a mutable to an immutable pointer that is normally provided by the
486
- /// compiler.
481
+ /// This overload of `callAsFunction(_:_:)` handles the implicit conversions
482
+ /// between various pointer types that are normally provided by the compiler.
487
483
///
488
484
/// - Warning: This function is used to implement the `#expect()` and
489
485
/// `#require()` macros. Do not call it directly.
490
- public mutating func callAsFunction( _ value: UnsafeMutableRawPointer , _ id: __ExpressionID ) -> UnsafeRawPointer {
491
- UnsafeRawPointer ( self ( value, id) as UnsafeMutableRawPointer )
486
+ public mutating func callAsFunction< P > ( _ value: P , _ id: __ExpressionID ) -> UnsafeRawPointer where P : _Pointer {
487
+ self ( value as P ? , id) !
492
488
}
493
489
494
- /// Convert an optional mutable raw pointer to an immutable one and capture
495
- /// information about it for use if the expectation currently being evaluated
496
- /// fails.
490
+ /// Convert some pointer to an immutable one and capture information about it
491
+ /// for use if the expectation currently being evaluated fails.
497
492
///
498
493
/// - Parameters:
499
- /// - value: The pointer to make immutable, or `nil` .
494
+ /// - value: The pointer to make immutable.
500
495
/// - id: A value that uniquely identifies the represented expression in the
501
496
/// context of the expectation currently being evaluated.
502
497
///
503
- /// - Returns: `value`, cast to an immutable raw pointer.
498
+ /// - Returns: `value`, cast to an immutable pointer.
504
499
///
505
- /// This overload of `callAsFunction(_:_:)` handles the implicit conversion
506
- /// from a mutable to an immutable pointer that is normally provided by the
507
- /// compiler.
500
+ /// This overload of `callAsFunction(_:_:)` handles the implicit conversions
501
+ /// between various pointer types that are normally provided by the compiler.
508
502
///
509
503
/// - Warning: This function is used to implement the `#expect()` and
510
504
/// `#require()` macros. Do not call it directly.
511
- public mutating func callAsFunction( _ value: UnsafeMutableRawPointer ? , _ id: __ExpressionID ) -> UnsafeRawPointer ? {
512
- UnsafeRawPointer ( self ( value, id) as UnsafeMutableRawPointer ? )
505
+ public mutating func callAsFunction< P > ( _ value: P ? , _ id: __ExpressionID ) -> UnsafeRawPointer ? where P : _Pointer {
506
+ UnsafeRawPointer ( bitPattern : Int ( bitPattern : self ( value, id) as P ? ) )
513
507
}
514
508
}
515
509
@@ -539,9 +533,9 @@ extension __ExpectationContext {
539
533
///
540
534
/// - Warning: This function is used to implement the `#expect()` and
541
535
/// `#require()` macros. Do not call it directly.
542
- public mutating func callAsFunction< P> ( _ value: String , _ id: __ExpressionID ) -> P where P: _Pointer {
536
+ public mutating func callAsFunction< P> ( _ value: String , _ id: __ExpressionID ) -> P where P: _Pointer , P . Pointee == CChar {
543
537
// Perform the normal value capture.
544
- let result = self ( value, id)
538
+ let result = self ( value, id) as String
545
539
546
540
// Create a C string copy of `value`.
547
541
#if os(Windows)
0 commit comments