[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
This commit is contained in:
Ben Cohen
2017-12-08 12:00:23 -08:00
committed by GitHub
parent ddac6ab1b9
commit 4ddac3fbbd
60 changed files with 268 additions and 302 deletions

View File

@@ -96,7 +96,6 @@ extension String {
}
public typealias Index = String.Index
public typealias IndexDistance = Int
/// Translates a `_core` index into a `UnicodeScalarIndex` using this view's
/// `_coreOffset`.
@@ -528,14 +527,14 @@ extension String.UnicodeScalarView {
@available(
swift, obsoleted: 4.0,
message: "Any String view index conversion can fail in Swift 4; please unwrap the optional index")
public func index(_ i: Index?, offsetBy n: IndexDistance) -> Index {
public func index(_ i: Index?, offsetBy n: Int) -> Index {
return index(i!, offsetBy: n)
}
@_inlineable // FIXME(sil-serialize-all)
@available(
swift, obsoleted: 4.0,
message: "Any String view index conversion can fail in Swift 4; please unwrap the optional indices")
public func distance(from i: Index?, to j: Index?) -> IndexDistance {
public func distance(from i: Index?, to j: Index?) -> Int {
return distance(from: i!, to: j!)
}
@_inlineable // FIXME(sil-serialize-all)