@@ -115,7 +115,7 @@ extension EnumeratedSequence: Collection where Base: Collection {
115115 @_alwaysEmitIntoClient
116116 init ( base: Base . Index , offset: Int ) {
117117 self . base = base
118- self . offset = offset
118+ self . _offset = offset
119119 }
120120 }
121121
@@ -150,7 +150,7 @@ extension EnumeratedSequence: Collection where Base: Collection {
150150 @available ( SwiftStdlib 6 . 1 , * )
151151 @_alwaysEmitIntoClient
152152 func _offset( of index: Index ) -> Int {
153- index. base == _base. endIndex ? _base. count : index. offset
153+ index. base == _base. endIndex ? _base. count : index. _offset
154154 }
155155
156156 @available ( SwiftStdlib 6 . 1 , * )
@@ -159,21 +159,21 @@ extension EnumeratedSequence: Collection where Base: Collection {
159159 if start. base == _base. endIndex || end. base == _base. endIndex {
160160 return _base. distance ( from: start. base, to: end. base)
161161 } else {
162- return end. offset - start. offset
162+ return end. _offset - start. _offset
163163 }
164164 }
165165
166166 @available ( SwiftStdlib 6 . 1 , * )
167167 @_alwaysEmitIntoClient
168168 public func index( after index: Index ) -> Index {
169- Index ( base: _base. index ( after: index. base) , offset: index. offset + 1 )
169+ Index ( base: _base. index ( after: index. base) , offset: index. _offset + 1 )
170170 }
171171
172172 @available ( SwiftStdlib 6 . 1 , * )
173173 @_alwaysEmitIntoClient
174174 public func index( _ i: Index , offsetBy distance: Int ) -> Index {
175175 let index = _base. index ( i. base, offsetBy: distance)
176- let offset = distance >= 0 ? i. offset : _offset ( of: i)
176+ let offset = distance >= 0 ? i. _offset : _offset ( of: i)
177177 return Index ( base: index, offset: offset + distance)
178178 }
179179
@@ -187,32 +187,32 @@ extension EnumeratedSequence: Collection where Base: Collection {
187187 guard let index = _base. index (
188188 i. base,
189189 offsetBy: distance,
190- limitedBy: limit
190+ limitedBy: limit. base
191191 ) else {
192192 return nil
193193 }
194194
195- let offset = distance >= 0 ? i. offset : _offset ( of: i)
195+ let offset = distance >= 0 ? i. _offset : _offset ( of: i)
196196 return Index ( base: index, offset: offset + distance)
197197 }
198198
199199 @available ( SwiftStdlib 6 . 1 , * )
200200 @_alwaysEmitIntoClient
201- public subscript( _ position: Int ) -> Element {
201+ public subscript( _ position: Index ) -> Element {
202202 _precondition (
203203 _base. startIndex <= position. base && position. base < _base. endIndex,
204204 " Index out of bounds "
205205 )
206206
207- return ( position. offset , _base [ position. base] )
207+ return ( position. _offset , _base [ position. base] )
208208 }
209209}
210210
211211@available ( SwiftStdlib 6 . 1 , * )
212212extension EnumeratedSequence . Index : Comparable {
213213 @available ( SwiftStdlib 6 . 1 , * )
214214 @_alwaysEmitIntoClient
215- public static == ( lhs: Self , rhs: Self ) -> Bool {
215+ public static func == ( lhs: Self , rhs: Self ) -> Bool {
216216 lhs. base == rhs. base
217217 }
218218
@@ -224,7 +224,7 @@ extension EnumeratedSequence.Index: Comparable {
224224}
225225
226226@available ( SwiftStdlib 6 . 1 , * )
227- extension EnumeratedSequence : BidirectionalCollection where Base: BidirectionalCollection {
227+ extension EnumeratedSequence : BidirectionalCollection where Base: BidirectionalCollection & RandomAccessCollection {
228228 @available ( SwiftStdlib 6 . 1 , * )
229229 @_alwaysEmitIntoClient
230230 public func index( before index: Index ) -> Index {
0 commit comments