mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
26 lines
553 B
Swift
26 lines
553 B
Swift
// RUN: not %target-swift-frontend -typecheck %s
|
|
|
|
// https://github.com/apple/swift/issues/55135
|
|
|
|
struct CountSteps1<T> : Collection {
|
|
init(count: Int) { self.count = count }
|
|
var count: Int
|
|
|
|
var startIndex: Int { 0 }
|
|
var endIndex: Int { count }
|
|
func index(after i: Int) -> Int {
|
|
totalSteps += 1
|
|
return i + 1
|
|
}
|
|
subscript(i: Int) -> Int { return i }
|
|
}
|
|
|
|
extension CountSteps1
|
|
: RandomAccessCollection, BidirectionalCollection
|
|
where T : Equatable
|
|
{
|
|
func index(_ i: Index, offsetBy d: Int) -> Index {
|
|
return i + d
|
|
}
|
|
}
|