Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0080-rdar30442622.swift
Ben Cohen 4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00

27 lines
1006 B
Swift

// RUN: %target-swift-frontend -typecheck -primary-file %s
protocol AnyCodeUnits_ {
typealias Index = Int64
typealias Element = UInt32
var startIndex: Index { get }
var endIndex: Index { get }
func index(after: Index) -> Index
func index(before: Index) -> Index
func index(_ i: Index, offsetBy: Int64) -> Index
subscript(i: Index) -> Element { get }
subscript(r: Range<Index>) -> AnyCodeUnits { get }
}
struct AnyCodeUnits : RandomAccessCollection, AnyCodeUnits_ {
let me: AnyCodeUnits_
typealias Indices = DefaultRandomAccessIndices<AnyCodeUnits>
var startIndex: Int64 { return me.startIndex }
var endIndex: Int64 { return me.endIndex }
func index(after i: Index) -> Index { return me.index(after: i) }
func index(before i: Index) -> Index { return me.index(before: i) }
func index(_ i: Index, offsetBy: Int64) -> Index { return me.index(i, offsetBy: i) }
subscript(i: Index) -> Element { return me[i] }
subscript(r: Range<Index>) -> AnyCodeUnits { return me[r] }
}