@@ -4182,7 +4182,7 @@ final class SwiftDriverTests: XCTestCase {
4182
4182
" -emit-module-path " , " target.swiftmodule " ,
4183
4183
" -emit-variant-module-path " , " variant.swiftmodule " ,
4184
4184
" -Xfrontend " , " -emit-module-doc-path " , " -Xfrontend " , " target.swiftdoc " ,
4185
- " -Xfrontend " , " -emit-variant-module-doc-path " , " variant.swiftdoc " ,
4185
+ " -Xfrontend " , " -emit-variant-module-doc-path " , " -Xfrontend " , " variant.swiftdoc " ,
4186
4186
" -emit-module-source-info-path " , " target.sourceinfo " ,
4187
4187
" -emit-variant-module-source-info-path " , " variant.sourceinfo " ,
4188
4188
" -emit-package-module-interface-path " , " target.package.swiftinterface " ,
@@ -8323,7 +8323,7 @@ func assertString(
8323
8323
""" , file: file, line: line)
8324
8324
}
8325
8325
8326
- extension Array where Element: Equatable {
8326
+ extension BidirectionalCollection where Element: Equatable , Index : Strideable , Index . Stride : SignedInteger {
8327
8327
/// Returns true if the receiver contains the given elements as a subsequence
8328
8328
/// (i.e., all elements are present, contiguous, and in the same order).
8329
8329
///
@@ -8337,10 +8337,15 @@ extension Array where Element: Equatable {
8337
8337
{
8338
8338
precondition ( !subsequence. isEmpty, " Subsequence may not be empty " )
8339
8339
8340
- let subsequenceCount = subsequence. count
8341
- for index in 0 ... ( self . count - subsequence. count) {
8342
- let subsequenceEnd = index + subsequenceCount
8343
- if self [ index..< subsequenceEnd] . elementsEqual ( subsequence) {
8340
+ guard self . count >= subsequence. count else {
8341
+ return false
8342
+ }
8343
+
8344
+ for index in self . startIndex... self . index ( self . endIndex,
8345
+ offsetBy: - subsequence. count) {
8346
+ if self [ index..< self . index ( index,
8347
+ offsetBy: subsequence. count) ]
8348
+ . elementsEqual ( subsequence) {
8344
8349
return true
8345
8350
}
8346
8351
}
0 commit comments