Skip to content

Commit 62f73f4

Browse files
committed
Rename CollectionDefaultIterator to IndexingIterator
1 parent a34a44f commit 62f73f4

20 files changed

+50
-50
lines changed

stdlib/public/core/Collection.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// This protocol is almost an implementation detail of the standard
2020
// library; it is used to deduce things like the `SubSequence` and
2121
// `Iterator` type from a minimal collection, but it is also used in
22-
// exposed places like as a constraint on CollectionDefaultIterator.
22+
// exposed places like as a constraint on IndexingIterator.
2323
public protocol Indexable {
2424
/// A type that represents a valid position in the collection.
2525
///
@@ -46,7 +46,7 @@ public protocol Indexable {
4646
// The declaration of _Element and subscript here is a trick used to
4747
// break a cyclic conformance/deduction that Swift can't handle. We
4848
// need something other than a Collection.Iterator.Element that can
49-
// be used as CollectionDefaultIterator<T>'s Element. Here we arrange for
49+
// be used as IndexingIterator<T>'s Element. Here we arrange for
5050
// the Collection itself to have an Element type that's deducible from
5151
// its subscript. Ideally we'd like to constrain this Element to be the same
5252
// as Collection.Iterator.Element (see below), but we have no way of
@@ -71,7 +71,7 @@ public protocol MutableIndexable {
7171
}
7272

7373
/// The iterator used for collections that don't specify one.
74-
public struct CollectionDefaultIterator<Elements : Indexable>
74+
public struct IndexingIterator<Elements : Indexable>
7575
: IteratorProtocol, Sequence {
7676

7777
/// Create a *iterator* over the given collection.
@@ -115,13 +115,13 @@ public protocol Collection : Indexable, Sequence {
115115
/// encapsulates its iteration state.
116116
///
117117
/// By default, a `Collection` satisfies `Sequence` by
118-
/// supplying a `CollectionDefaultIterator` as its associated `Iterator`
118+
/// supplying a `IndexingIterator` as its associated `Iterator`
119119
/// type.
120-
associatedtype Iterator : IteratorProtocol = CollectionDefaultIterator<Self>
120+
associatedtype Iterator : IteratorProtocol = IndexingIterator<Self>
121121

122122
// FIXME: Needed here so that the Iterator is properly deduced from
123123
// a custom iterator() function. Otherwise we get an
124-
// CollectionDefaultIterator. <rdar://problem/21539115>
124+
// IndexingIterator. <rdar://problem/21539115>
125125
func iterator() -> Iterator
126126

127127
// FIXME: should be constrained to Collection
@@ -189,10 +189,10 @@ public protocol Collection : Indexable, Sequence {
189189

190190
/// Supply the default `iterator()` method for `Collection` models
191191
/// that accept the default associated `Iterator`,
192-
/// `CollectionDefaultIterator<Self>`.
193-
extension Collection where Iterator == CollectionDefaultIterator<Self> {
194-
public func iterator() -> CollectionDefaultIterator<Self> {
195-
return CollectionDefaultIterator(self)
192+
/// `IndexingIterator<Self>`.
193+
extension Collection where Iterator == IndexingIterator<Self> {
194+
public func iterator() -> IndexingIterator<Self> {
195+
return IndexingIterator(self)
196196
}
197197
}
198198

stdlib/public/core/Reverse.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public struct ReverseCollection<
155155

156156
/// A type that provides the *sequence*'s iteration interface and
157157
/// encapsulates its iteration state.
158-
public typealias Iterator = CollectionDefaultIterator<ReverseCollection>
158+
public typealias Iterator = IndexingIterator<ReverseCollection>
159159

160160
public let _base: Base
161161
}
@@ -185,7 +185,7 @@ public struct ReverseRandomAccessCollection<
185185

186186
/// A type that provides the *sequence*'s iteration interface and
187187
/// encapsulates its iteration state.
188-
public typealias Iterator = CollectionDefaultIterator<
188+
public typealias Iterator = IndexingIterator<
189189
ReverseRandomAccessCollection
190190
>
191191

stdlib/public/core/StringUnicodeScalarView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ extension String {
198198
internal let _ascii: Bool
199199
internal var _asciiBase: UnsafeBufferPointerIterator<UInt8>!
200200
internal var _base: UnsafeBufferPointerIterator<UInt16>!
201-
internal var _iterator: CollectionDefaultIterator<_StringCore>!
201+
internal var _iterator: IndexingIterator<_StringCore>!
202202
}
203203

204204
/// Return an *iterator* over the `UnicodeScalar`s that comprise

test/1_stdlib/ArrayCore.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ struct MrMcRange : Collection {
6565
self.base = base
6666
}
6767

68-
func iterator() -> CollectionDefaultIterator<MrMcRange> {
69-
return CollectionDefaultIterator(self)
68+
func iterator() -> IndexingIterator<MrMcRange> {
69+
return IndexingIterator(self)
7070
}
7171

7272
var startIndex: Int {

test/1_stdlib/Collection.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ struct X : Collection {
6262
}
6363
subscript(i: Index) -> Element { return msg[i] }
6464

65-
func iterator() -> CollectionDefaultIterator<X> {
66-
return CollectionDefaultIterator(self)
65+
func iterator() -> IndexingIterator<X> {
66+
return IndexingIterator(self)
6767
}
6868
}
6969

test/1_stdlib/Sort.swift.gyb

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class OffsetCollection : MutableCollection {
7575
get { return data[i - startIndex] }
7676
set { data[i - startIndex] = newValue }
7777
}
78-
func iterator() -> CollectionDefaultIterator<[Int]> {
79-
return CollectionDefaultIterator<[Int]>(data)
78+
func iterator() -> IndexingIterator<[Int]> {
79+
return IndexingIterator<[Int]>(data)
8080
}
8181
func toArray() -> [Int] {
8282
return data

test/Constraints/recursive_concrete_constraints.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct S<A: Collection where A.Index == Int> : Collection {
2121
return base[baseRange.startIndex + i]
2222
}
2323

24-
func iterator() -> CollectionDefaultIterator<S> {
25-
return CollectionDefaultIterator(self)
24+
func iterator() -> IndexingIterator<S> {
25+
return IndexingIterator(self)
2626
}
2727

2828
var base: A

test/Generics/deduction.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func rangeOfIsBefore<
216216

217217
func callRangeOfIsBefore(ia: [Int], da: [Double]) {
218218
rangeOfIsBefore(ia.iterator())
219-
rangeOfIsBefore(da.iterator()) // expected-error{{cannot invoke 'rangeOfIsBefore' with an argument list of type '(CollectionDefaultIterator<[Double]>)'}} expected-note{{expected an argument list of type '(R)'}}
219+
rangeOfIsBefore(da.iterator()) // expected-error{{cannot invoke 'rangeOfIsBefore' with an argument list of type '(IndexingIterator<[Double]>)'}} expected-note{{expected an argument list of type '(R)'}}
220220
}
221221

222222
//===----------------------------------------------------------------------===//

test/IDE/complete_from_stdlib.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func testArchetypeReplacement1<FOO : Equatable>(a: [FOO]) {
123123
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/CurrNominal: append({#(newElement): Equatable#})[#Void#]{{; name=.+}}
124124
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/CurrNominal: insert({#(newElement): Equatable#}, {#at: Int#})[#Void#]{{; name=.+}}
125125
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/CurrNominal: popLast()[#Equatable?#]{{; name=.+}}
126-
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/Super: iterator()[#CollectionDefaultIterator<[Equatable]>#]{{; name=.+}}
126+
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/Super: iterator()[#IndexingIterator<[Equatable]>#]{{; name=.+}}
127127
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceVar]/Super: isEmpty[#Bool#]{{; name=.+}}
128128
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceVar]/Super: first[#Equatable?#]{{; name=.+}}
129129
// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/Super: dropFirst({#(n): Int#})[#ArraySlice<Equatable>#]{{; name=.+}}

test/NameBinding/reference-dependencies.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ struct Sentinel2 {}
374374
// CHECK-DAG: - !private ["V4main28OtherFileProtoNonImplementor", "deinit"]
375375
// CHECK-DAG: - !private ["Vs13EmptyIterator", "Element"]
376376
// CHECK-DAG: - !private ["Vs13EmptyIterator", "init"]
377-
// CHECK-DAG: - !private ["Vs25CollectionDefaultIterator", "Element"]
377+
// CHECK-DAG: - !private ["Vs16IndexingIterator", "Element"]
378378
// CHECK-DAG: - ["O4main13OtherFileEnum", "Value"]
379379
// CHECK-DAG: - !private ["V4main20OtherFileEnumWrapper", "Enum"]
380380

@@ -413,7 +413,7 @@ struct Sentinel2 {}
413413
// CHECK-DAG: !private "V4main26OtherFileProtoImplementor2"
414414
// CHECK-DAG: !private "V4main28OtherFileProtoNonImplementor"
415415
// CHECK-DAG: !private "Vs13EmptyIterator"
416-
// CHECK-DAG: !private "Vs25CollectionDefaultIterator"
416+
// CHECK-DAG: !private "Vs16IndexingIterator"
417417
// CHECK-DAG: - "O4main13OtherFileEnum"
418418
// CHECK-DAG: !private "V4main20OtherFileEnumWrapper"
419419
// CHECK-DAG: !private "V4main20OtherFileEnumWrapper"

test/Prototypes/MutableIndexableDict.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ struct Dictionary<Key: Hashable, Value> : Collection, Sequence {
416416
}
417417

418418
// Satisfying Sequence
419-
func iterator() -> CollectionDefaultIterator<_Self> {
420-
return CollectionDefaultIterator(self)
419+
func iterator() -> IndexingIterator<_Self> {
420+
return IndexingIterator(self)
421421
}
422422
}
423423

test/SIL/Parser/witness_with_inherited_gp.sil

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ public struct _mmArrayBuffer<T> : Collection {
4343
public var startIndex: Int { get }
4444
public var endIndex: Int { get }
4545
public subscript(i: Int) -> T { get }
46-
public func iterator() -> CollectionDefaultIterator<_mmArrayBuffer>
46+
public func iterator() -> IndexingIterator<_mmArrayBuffer>
4747
}
4848

4949
sil_witness_table <T> _mmArrayBuffer<T>: _Sequence_Type module WitnessTableWithGP {
5050
base_protocol _SequenceType: <T> _mmArrayBuffer<T>: _SequenceType module WitnessTableWithGP
51-
associated_type Generator: CollectionDefaultIterator<_mmArrayBuffer<T>>
52-
associated_type_protocol (Generator: GeneratorType): CollectionDefaultIterator<_mmArrayBuffer<T>>: specialize <C = _mmArrayBuffer<T>, C.Index = Int, C.Index.Distance = Int, C.Index.Distance.IntegerLiteralType = Int, C.Index._DisabledRangeIndex = Int, C._Element = T> (<C : _CollectionType> CollectionDefaultIterator<C>: GeneratorType module Swift)
51+
associated_type Generator: IndexingIterator<_mmArrayBuffer<T>>
52+
associated_type_protocol (Generator: GeneratorType): IndexingIterator<_mmArrayBuffer<T>>: specialize <C = _mmArrayBuffer<T>, C.Index = Int, C.Index.Distance = Int, C.Index.Distance.IntegerLiteralType = Int, C.Index._DisabledRangeIndex = Int, C._Element = T> (<C : _CollectionType> IndexingIterator<C>: GeneratorType module Swift)
5353
}
5454

5555
// CHECK: sil_witness_table <T> _mmArrayBuffer<T>: _Sequence_Type module WitnessTableWithGP {
5656
// CHECK: base_protocol _SequenceType: <T> _mmArrayBuffer<T>: _SequenceType module WitnessTableWithGP
57-
// CHECK: associated_type Generator: CollectionDefaultIterator<_mmArrayBuffer<T>>
58-
// CHECK: associated_type_protocol (Generator: GeneratorType): CollectionDefaultIterator<_mmArrayBuffer<T>>: specialize <C = _mmArrayBuffer<T>, C.Index = Int, C.Index.Distance = Int, C.Index.Distance.IntegerLiteralType = Int, C.Index._DisabledRangeIndex = Int, C._Element = T> (<C where C : _CollectionType, C.Index : ForwardIndex, C.Index.Distance : _SignedInteger, C.Index.Distance.IntegerLiteralType : _BuiltinIntegerLiteralConvertible> CollectionDefaultIterator<C>: GeneratorType module Swift)
57+
// CHECK: associated_type Generator: IndexingIterator<_mmArrayBuffer<T>>
58+
// CHECK: associated_type_protocol (Generator: GeneratorType): IndexingIterator<_mmArrayBuffer<T>>: specialize <C = _mmArrayBuffer<T>, C.Index = Int, C.Index.Distance = Int, C.Index.Distance.IntegerLiteralType = Int, C.Index._DisabledRangeIndex = Int, C._Element = T> (<C where C : _CollectionType, C.Index : ForwardIndex, C.Index.Distance : _SignedInteger, C.Index.Distance.IntegerLiteralType : _BuiltinIntegerLiteralConvertible> IndexingIterator<C>: GeneratorType module Swift)

test/SILGen/statements.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func for_loops1(x: Int, c: Bool) {
176176
// CHECK-LABEL: sil hidden @{{.*}}for_loops2
177177
func for_loops2() {
178178
// rdar://problem/19316670
179-
// CHECK: [[NEXT:%[0-9]+]] = function_ref @_TFVs25CollectionDefaultIterator4next
179+
// CHECK: [[NEXT:%[0-9]+]] = function_ref @_TFVs16IndexingIterator4next
180180
// CHECK-NEXT: alloc_stack $Optional<MyClass>
181181
// CHECK-NEXT: apply [[NEXT]]<Array<MyClass>,
182182
// CHECK: class_method [[OBJ:%[0-9]+]] : $MyClass, #MyClass.foo!1

test/SILOptimizer/devirt_type_subst_bug.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// %168 = witness_method $Array<String>, #Sequence."~>"!1 : $@convention(witness_method) <τ_0_0, τ_1_0 where τ_0_0 : Sequence, τ_0_0.Generator : Generator> (@out Optional<τ_1_0>, @in τ_0_0, _PreprocessingPass, @owned @callee_owned (@out τ_1_0, @in τ_0_0) -> (), @thick τ_0_0.Type) -> ()
66
// ...
7-
// %181 = apply %168<Array<String>, CollectionDefaultIterator<Array<String>>, String, Int>(%166#1, %169#1, %180, %179, %167) : $@convention(witness_method) <τ_0_0, τ_1_0 where τ_0_0 : Sequence, τ_0_0.Generator : Generator> (@out Optional<τ_1_0>, @in τ_0_0, _PreprocessingPass, @owned @callee_owned (@out τ_1_0, @in τ_0_0) -> (), @thick τ_0_0.Type) -> ()
7+
// %181 = apply %168<Array<String>, IndexingIterator<Array<String>>, String, Int>(%166#1, %169#1, %180, %179, %167) : $@convention(witness_method) <τ_0_0, τ_1_0 where τ_0_0 : Sequence, τ_0_0.Generator : Generator> (@out Optional<τ_1_0>, @in τ_0_0, _PreprocessingPass, @owned @callee_owned (@out τ_1_0, @in τ_0_0) -> (), @thick τ_0_0.Type) -> ()
88
//
99
// rdar://17399536
1010
// rdar://17440222

test/Serialization/Inputs/inherited-conformance-user.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public struct OneToAThousand : Collection {
1717
return i.value
1818
}
1919

20-
public func iterator() -> CollectionDefaultIterator<OneToAThousand> {
21-
return CollectionDefaultIterator(self)
20+
public func iterator() -> IndexingIterator<OneToAThousand> {
21+
return IndexingIterator(self)
2222
}
2323

2424
public init() {}

validation-test/compiler_crashers_2_fixed/0018-rdar21524144.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public protocol Indexable {
1010

1111
protocol Collection : Indexable, Sequence {}
1212

13-
public struct CollectionDefaultIterator<Elements : Indexable>
13+
public struct IndexingIterator<Elements : Indexable>
1414
: IteratorProtocol, Sequence {
1515

16-
public func iterator() -> CollectionDefaultIterator {
16+
public func iterator() -> IndexingIterator {
1717
return self
1818
}
1919

@@ -23,8 +23,8 @@ public struct CollectionDefaultIterator<Elements : Indexable>
2323
}
2424

2525
extension Sequence where Self : Collection {
26-
func iterator() -> CollectionDefaultIterator<Self> {
27-
return CollectionDefaultIterator(self)
26+
func iterator() -> IndexingIterator<Self> {
27+
return IndexingIterator(self)
2828
}
2929
}
3030

validation-test/stdlib/ArrayNew.swift.gyb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,8 @@ final class EvilCollection : Collection {
16021602
return TestValueTy(i)
16031603
}
16041604

1605-
func iterator() -> CollectionDefaultIterator<EvilCollection> {
1606-
return CollectionDefaultIterator(self)
1605+
func iterator() -> IndexingIterator<EvilCollection> {
1606+
return IndexingIterator(self)
16071607
}
16081608
}
16091609

validation-test/stdlib/CollectionType.swift.gyb

+2-2
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ CollectionTypeTests.test("Collection.iterator()/DefaultImplementation") {
422422
// Check the return type of the function when called statically.
423423
var iter = collection.iterator()
424424
expectType(
425-
CollectionDefaultIterator<MinimalForwardCollectionWithDefaultIterator>.self,
425+
IndexingIterator<MinimalForwardCollectionWithDefaultIterator>.self,
426426
&iter)
427427
}
428428

429429
do {
430430
// Check the return type of the function when called generically.
431431
var iter = callGenericIterator(collection)
432432
expectType(
433-
CollectionDefaultIterator<MinimalForwardCollectionWithDefaultIterator>.self,
433+
IndexingIterator<MinimalForwardCollectionWithDefaultIterator>.self,
434434
&iter)
435435
}
436436

validation-test/stdlib/SequenceType.swift.gyb

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ SequenceTypeTests.test("IteratorSequence/IteratorProtocol/empty") {
171171
let base = data.iterator()
172172
var iter = IteratorSequence(base)
173173
expectType(
174-
IteratorSequence<CollectionDefaultIterator<Array<OpaqueValue<Int>>>>.self,
174+
IteratorSequence<IndexingIterator<Array<OpaqueValue<Int>>>>.self,
175175
&iter)
176176
checkIterator(data, iter) { $0.value == $1.value }
177177
}
@@ -192,7 +192,7 @@ SequenceTypeTests.test("IteratorSequence/IteratorProtocol") {
192192
let base = data.iterator()
193193
var iter = IteratorSequence(base)
194194
expectType(
195-
IteratorSequence<CollectionDefaultIterator<Array<OpaqueValue<Int>>>>.self,
195+
IteratorSequence<IndexingIterator<Array<OpaqueValue<Int>>>>.self,
196196
&iter)
197197
checkIterator(data, iter) { $0.value == $1.value }
198198
}
@@ -213,7 +213,7 @@ SequenceTypeTests.test("IteratorSequence/Sequence/empty") {
213213
let base = data.iterator()
214214
var iter = IteratorSequence(base)
215215
expectType(
216-
IteratorSequence<CollectionDefaultIterator<Array<OpaqueValue<Int>>>>.self,
216+
IteratorSequence<IndexingIterator<Array<OpaqueValue<Int>>>>.self,
217217
&iter)
218218
checkSequence(data, iter) { $0.value == $1.value }
219219
}
@@ -234,7 +234,7 @@ SequenceTypeTests.test("IteratorSequence/Sequence") {
234234
let base = data.iterator()
235235
var iter = IteratorSequence(base)
236236
expectType(
237-
IteratorSequence<CollectionDefaultIterator<Array<OpaqueValue<Int>>>>.self,
237+
IteratorSequence<IndexingIterator<Array<OpaqueValue<Int>>>>.self,
238238
&iter)
239239
checkSequence(data, iter) { $0.value == $1.value }
240240
}

validation-test/stdlib/Slice.swift.gyb

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SliceTests.test("Slice/AssociatedTypes") {
2929
expectSliceType(${traversal}Slice.self)
3030
expectCollectionAssociatedTypes(
3131
collectionType: ${traversal}Slice.self,
32-
iteratorType: CollectionDefaultIterator<${traversal}Slice>.self,
32+
iteratorType: IndexingIterator<${traversal}Slice>.self,
3333
subSequenceType: ${traversal}Slice.self,
3434
indexType: Minimal${traversal}Index.self)
3535
}
@@ -143,7 +143,7 @@ SliceTests.test("MutableSlice/AssociatedTypes") {
143143
expectMutableSliceType(${traversal}MutableSlice.self)
144144
expectCollectionAssociatedTypes(
145145
collectionType: ${traversal}MutableSlice.self,
146-
iteratorType: CollectionDefaultIterator<${traversal}MutableSlice>.self,
146+
iteratorType: IndexingIterator<${traversal}MutableSlice>.self,
147147
subSequenceType: ${traversal}MutableSlice.self,
148148
indexType: Minimal${traversal}Index.self)
149149
}

0 commit comments

Comments
 (0)