@@ -430,8 +430,8 @@ extension __ExpectationContext {
430430// MARK: - Implicit pointer conversion
431431
432432extension __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.
435435 ///
436436 /// - Parameters:
437437 /// - value: The pointer to make immutable.
@@ -440,76 +440,70 @@ extension __ExpectationContext {
440440 ///
441441 /// - Returns: `value`, cast to an immutable pointer.
442442 ///
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.
446445 ///
447446 /// - Warning: This function is used to implement the `#expect()` and
448447 /// `#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) !
451450 }
452451
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.
456454 ///
457455 /// - Parameters:
458- /// - value: The pointer to make immutable, or `nil` .
456+ /// - value: The pointer to make immutable.
459457 /// - id: A value that uniquely identifies the represented expression in the
460458 /// context of the expectation currently being evaluated.
461459 ///
462460 /// - Returns: `value`, cast to an immutable pointer.
463461 ///
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.
467464 ///
468465 /// - Warning: This function is used to implement the `#expect()` and
469466 /// `#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 ? ) )
472469 }
473470
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.
476473 ///
477474 /// - Parameters:
478475 /// - value: The pointer to make immutable.
479476 /// - id: A value that uniquely identifies the represented expression in the
480477 /// context of the expectation currently being evaluated.
481478 ///
482- /// - Returns: `value`, cast to an immutable raw pointer.
479+ /// - Returns: `value`, cast to an immutable pointer.
483480 ///
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.
487483 ///
488484 /// - Warning: This function is used to implement the `#expect()` and
489485 /// `#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) !
492488 }
493489
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.
497492 ///
498493 /// - Parameters:
499- /// - value: The pointer to make immutable, or `nil` .
494+ /// - value: The pointer to make immutable.
500495 /// - id: A value that uniquely identifies the represented expression in the
501496 /// context of the expectation currently being evaluated.
502497 ///
503- /// - Returns: `value`, cast to an immutable raw pointer.
498+ /// - Returns: `value`, cast to an immutable pointer.
504499 ///
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.
508502 ///
509503 /// - Warning: This function is used to implement the `#expect()` and
510504 /// `#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 ? ) )
513507 }
514508}
515509
@@ -539,9 +533,9 @@ extension __ExpectationContext {
539533 ///
540534 /// - Warning: This function is used to implement the `#expect()` and
541535 /// `#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 {
543537 // Perform the normal value capture.
544- let result = self ( value, id)
538+ let result = self ( value, id) as String
545539
546540 // Create a C string copy of `value`.
547541#if os(Windows)
0 commit comments