[stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)

* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
This commit is contained in:
Ben Cohen
2017-05-14 06:33:25 -07:00
committed by GitHub
parent 2e275e3a13
commit ea2f64cad2
78 changed files with 503 additions and 500 deletions

View File

@@ -1083,7 +1083,7 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
/// - Parameter s: The sequence of elements to turn into an array.
@_inlineable
public init<S : Sequence>(_ s: S)
where S.Iterator.Element == Element {
where S.Element == Element {
self = ${Self}(
_buffer: _Buffer(
@@ -1436,7 +1436,7 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
@_inlineable
@_semantics("array.append_contentsOf")
public mutating func append<S : Sequence>(contentsOf newElements: S)
where S.Iterator.Element == Element {
where S.Element == Element {
let newElementsCount = newElements.underestimatedCount
reserveCapacityForAppend(newElementsCount: newElementsCount)
@@ -1779,8 +1779,8 @@ extension ${Self} {
@_inlineable
public func _copyContents(
initializing buffer: UnsafeMutableBufferPointer<Iterator.Element>
) -> (Iterator,UnsafeMutableBufferPointer<Iterator.Element>.Index) {
initializing buffer: UnsafeMutableBufferPointer<Element>
) -> (Iterator,UnsafeMutableBufferPointer<Element>.Index) {
guard !self.isEmpty else { return (makeIterator(),buffer.startIndex) }
@@ -1817,7 +1817,7 @@ internal struct _InitializeMemoryFromCollection<
> : _PointerFunction {
@_inlineable
@_versioned
func call(_ rawMemory: UnsafeMutablePointer<C.Iterator.Element>, count: Int) {
func call(_ rawMemory: UnsafeMutablePointer<C.Element>, count: Int) {
var p = rawMemory
var q = newValues.startIndex
for _ in 0..<count {
@@ -1846,7 +1846,7 @@ extension _ArrayBufferProtocol {
_ bounds: Range<Int>,
with newValues: C,
count insertCount: Int
) where C.Iterator.Element == Element {
) where C.Element == Element {
let growth = insertCount - bounds.count
let newCount = self.count + growth
@@ -1918,7 +1918,7 @@ extension ${Self} {
public mutating func replaceSubrange<C>(
_ subrange: Range<Int>,
with newElements: C
) where C : Collection, C.Iterator.Element == Element {
) where C : Collection, C.Element == Element {
% if Self in ['Array', 'ContiguousArray']:
_precondition(subrange.lowerBound >= self._buffer.startIndex,
"${Self} replace: subrange start is negative")
@@ -2131,7 +2131,7 @@ extension _ArrayBufferProtocol {
@_versioned
internal mutating func _arrayAppendSequence<S : Sequence>(
_ newItems: S
) where S.Iterator.Element == Element {
) where S.Element == Element {
// this function is only ever called from append(contentsOf:)
// which should always have exhausted its capacity before calling
@@ -2410,13 +2410,13 @@ extension ${Self} {
public mutating func replaceRange<C>(
_ subRange: Range<Int>,
with newElements: C
) where C : Collection, C.Iterator.Element == Element {
) where C : Collection, C.Element == Element {
Builtin.unreachable()
}
@available(*, unavailable, renamed: "append(contentsOf:)")
public mutating func appendContentsOf<S : Sequence>(_ newElements: S)
where S.Iterator.Element == Element {
where S.Element == Element {
Builtin.unreachable()
}
}