@@ -165,7 +165,7 @@ private func _callBinaryOperator<T, U, R>(
165
165
///
166
166
/// - Warning: This function is used to implement the `#expect()` and
167
167
/// `#require()` macros. Do not call it directly.
168
- public func __checkBinaryOperation< T, U> (
168
+ @ _disfavoredOverload public func __checkBinaryOperation< T, U> (
169
169
_ lhs: T , _ op: ( T , ( ) -> U ) -> Bool , _ rhs: @autoclosure ( ) -> U ,
170
170
expression: __Expression ,
171
171
comments: @autoclosure ( ) -> [ Comment ] ,
@@ -594,7 +594,7 @@ public func __checkPropertyAccess<T, U>(
594
594
///
595
595
/// - Warning: This function is used to implement the `#expect()` and
596
596
/// `#require()` macros. Do not call it directly.
597
- public func __checkBinaryOperation< T> (
597
+ @ _disfavoredOverload public func __checkBinaryOperation< T> (
598
598
_ lhs: T , _ op: ( T , ( ) -> T ) -> Bool , _ rhs: @autoclosure ( ) -> T ,
599
599
expression: __Expression ,
600
600
comments: @autoclosure ( ) -> [ Comment ] ,
@@ -660,6 +660,34 @@ public func __checkBinaryOperation(
660
660
)
661
661
}
662
662
663
+ /// Check that an expectation has passed after a condition has been evaluated
664
+ /// and throw an error if it failed.
665
+ ///
666
+ /// This overload is necessary because ranges are collections and satisfy the
667
+ /// requirements for the difference-calculating overload above, but it doesn't
668
+ /// make sense to diff them and very large ranges can cause overflows or hangs.
669
+ ///
670
+ /// - Warning: This function is used to implement the `#expect()` and
671
+ /// `#require()` macros. Do not call it directly.
672
+ public func __checkBinaryOperation< T, U> (
673
+ _ lhs: T , _ op: ( T , ( ) -> U ) -> Bool , _ rhs: @autoclosure ( ) -> U ,
674
+ expression: __Expression ,
675
+ comments: @autoclosure ( ) -> [ Comment ] ,
676
+ isRequired: Bool ,
677
+ sourceLocation: SourceLocation
678
+ ) -> Result < Void , any Error > where T: RangeExpression , U: RangeExpression {
679
+ let ( condition, rhs) = _callBinaryOperator ( lhs, op, rhs)
680
+ return __checkValue (
681
+ condition,
682
+ expression: expression,
683
+ expressionWithCapturedRuntimeValues: expression. capturingRuntimeValues ( lhs, rhs) ,
684
+ difference: nil ,
685
+ comments: comments ( ) ,
686
+ isRequired: isRequired,
687
+ sourceLocation: sourceLocation
688
+ )
689
+ }
690
+
663
691
/// Check that an expectation has passed after a condition has been evaluated
664
692
/// and throw an error if it failed.
665
693
///
0 commit comments