Skip to content

Commit 2857ec9

Browse files
authored
[SR-12881] DefaultIndices dynamic dispatch
As seen in SR-12881, `DefaultIndices` was not properly dispatching certain `Collection` requirements through conditional conformances to `BidirectionalCollection` and `RandomAccessCollection`. This should fix that.
1 parent 6bda828 commit 2857ec9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

stdlib/public/core/Indices.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ extension DefaultIndices: Collection {
8181
public var indices: Indices {
8282
return self
8383
}
84+
85+
@inlinable
86+
public func index(_ i: Index, offsetBy distance: Int) -> Index {
87+
return _elements.index(i, offsetBy: distance)
88+
}
89+
90+
@inlinable
91+
public func index(
92+
_ i: Index, offsetBy distance: Int, limitedBy limit: Index
93+
) -> Index? {
94+
return _elements.index(i, offsetBy: distance, limitedBy: limit)
95+
}
96+
97+
@inlinable
98+
public func distance(from start: Index, to end: Index) -> Int {
99+
return _elements.distance(from: start, to: end)
100+
}
84101
}
85102

86103
extension DefaultIndices: BidirectionalCollection

0 commit comments

Comments
 (0)