@@ -821,18 +821,11 @@ public func __checkCast<V, T>(
821821
822822// MARK: - Matching errors by type
823823
824- /// A placeholder type representing `Never` if a test attempts to instantiate it
825- /// by calling `#expect(throws:)` and taking the result.
826- ///
827- /// Errors of this type are never thrown; they act as placeholders in `Result`
828- /// so that `#expect(throws: Never.self)` always produces `nil` (since `Never`
829- /// cannot be instantiated.)
830- private struct _CannotInstantiateNeverError : Error { }
831-
832824/// Check that an expression always throws an error.
833825///
834826/// This overload is used for `#expect(throws:) { }` invocations that take error
835- /// types.
827+ /// types. It is disfavored so that `#expect(throws: Never.self)` preferentially
828+ /// returns `Void`.
836829///
837830/// - Warning: This function is used to implement the `#expect()` and
838831/// `#require()` macros. Do not call it directly.
@@ -869,7 +862,8 @@ public func __checkClosureCall<E>(
869862/// Check that an expression always throws an error.
870863///
871864/// This overload is used for `await #expect(throws:) { }` invocations that take
872- /// error types.
865+ /// error types. It is disfavored so that `#expect(throws: Never.self)`
866+ /// preferentially returns `Void`.
873867///
874868/// - Warning: This function is used to implement the `#expect()` and
875869/// `#require()` macros. Do not call it directly.
@@ -923,7 +917,7 @@ public func __checkClosureCall(
923917 comments: @autoclosure ( ) -> [ Comment ] ,
924918 isRequired: Bool ,
925919 sourceLocation: SourceLocation
926- ) -> Result < Never ? , any Error > {
920+ ) -> Result < Void , any Error > {
927921 var success = true
928922 var mismatchExplanationValue : String ? = nil
929923 do {
@@ -940,7 +934,7 @@ public func __checkClosureCall(
940934 comments: comments ( ) ,
941935 isRequired: isRequired,
942936 sourceLocation: sourceLocation
943- ) . map { _ in nil }
937+ ) . map { _ in }
944938}
945939
946940/// Check that an expression never throws an error.
@@ -960,7 +954,7 @@ public func __checkClosureCall(
960954 isRequired: Bool ,
961955 isolation: isolated ( any Actor ) ? = #isolation,
962956 sourceLocation: SourceLocation
963- ) async -> Result < Never ? , any Error > {
957+ ) async -> Result < Void , any Error > {
964958 var success = true
965959 var mismatchExplanationValue : String ? = nil
966960 do {
@@ -977,7 +971,7 @@ public func __checkClosureCall(
977971 comments: comments ( ) ,
978972 isRequired: isRequired,
979973 sourceLocation: sourceLocation
980- ) . map { _ in nil }
974+ ) . map { _ in }
981975}
982976
983977// MARK: - Matching instances of equatable errors
0 commit comments