From 1c0047829a0ed033c9f19c7ad03fffa482d84e9b Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Tue, 3 Nov 2015 15:48:40 -0800 Subject: [PATCH] Rename SequenceType.generate() to SequenceType.iterator() --- docs/SequencesAndCollections.rst | 14 ++-- docs/archive/LangRef.html | 2 +- docs/proposals/DeclarationTypeChecker.rst | 4 +- include/swift/AST/KnownIdentifiers.def | 2 +- lib/Sema/TypeCheckStmt.cpp | 4 +- .../StdlibUnittest/CheckCollectionType.swift | 4 +- .../StdlibUnittest/LoggingWrappers.swift.gyb | 8 +- .../StdlibUnittest/StdlibUnittest.swift.gyb | 24 +++--- stdlib/public/SDK/Foundation/Foundation.swift | 12 +-- stdlib/public/core/Algorithm.swift | 12 +-- stdlib/public/core/Arrays.swift.gyb | 6 +- stdlib/public/core/Character.swift | 6 +- stdlib/public/core/Collection.swift | 14 ++-- stdlib/public/core/CollectionOfOne.swift | 2 +- .../public/core/ContiguousArrayBuffer.swift | 2 +- stdlib/public/core/EmptyCollection.swift | 2 +- stdlib/public/core/Existential.swift | 2 +- .../core/ExistentialCollection.swift.gyb | 20 ++--- stdlib/public/core/Filter.swift | 8 +- stdlib/public/core/Flatten.swift.gyb | 10 +-- .../public/core/HashedCollections.swift.gyb | 12 +-- stdlib/public/core/Join.swift | 14 ++-- stdlib/public/core/LazyCollection.swift | 2 +- stdlib/public/core/LazySequence.swift | 4 +- stdlib/public/core/Map.swift | 8 +- stdlib/public/core/Range.swift | 2 +- stdlib/public/core/Sequence.swift | 76 +++++++++---------- .../public/core/SequenceAlgorithms.swift.gyb | 14 ++-- stdlib/public/core/SequenceWrapper.swift | 4 +- stdlib/public/core/Stride.swift | 4 +- stdlib/public/core/String.swift | 2 +- stdlib/public/core/StringBuffer.swift | 6 +- stdlib/public/core/StringCore.swift | 4 +- .../public/core/StringUnicodeScalarView.swift | 8 +- .../public/core/UnsafeBufferPointer.swift.gyb | 2 +- stdlib/public/core/Zip.swift | 6 +- test/1_stdlib/ArrayCore.swift | 4 +- test/1_stdlib/Collection.swift | 10 +-- test/1_stdlib/ExistentialCollection.swift | 2 +- test/1_stdlib/Filter.swift | 4 +- test/1_stdlib/Generator.swift | 4 +- test/1_stdlib/Lazy.swift.gyb | 14 ++-- test/1_stdlib/Map.swift | 4 +- test/1_stdlib/NSSetAPI.swift | 4 +- test/1_stdlib/SequenceWrapperTest.swift | 2 +- test/1_stdlib/Sort.swift.gyb | 2 +- test/Constraints/associated_self_types.swift | 2 +- .../invalid_constraint_lookup.swift | 4 +- test/Constraints/nested_generics.swift | 2 +- .../recursive_concrete_constraints.swift | 2 +- test/Generics/associated_types.swift | 2 +- test/Generics/deduction.swift | 4 +- test/Generics/function_defs.swift | 10 +-- test/Generics/generic_types.swift | 4 +- test/Generics/same_type_constraints.swift | 12 +-- test/IDE/Inputs/dumped_api.swift | 12 +-- test/IDE/complete_from_stdlib.swift | 2 +- test/IDE/dump_api.swift | 28 +++---- test/Interpreter/protocol_extensions.swift | 2 +- .../reference-dependencies-helper.swift | 2 +- test/Parse/foreach.swift | 2 +- test/Prototypes/MutableIndexableDict.swift | 2 +- test/SIL/Parser/witness_with_inherited_gp.sil | 6 +- test/SILGen/witness_same_type.swift | 4 +- test/SILPasses/prespecialize.swift | 4 +- .../Inputs/inherited-conformance-user.swift | 2 +- test/Serialization/multi-file.swift | 2 +- test/decl/protocol/protocols.swift | 10 +-- .../req/associated_type_inference.swift | 6 +- test/decl/protocol/substituted_aliases.swift | 4 +- test/decl/var/usage.swift | 2 +- test/stmt/foreach.swift | 10 +-- test/type/nested_types.swift | 6 +- .../0003-rdar20564378.swift | 14 ++-- .../0004-rdar20564605.swift | 14 ++-- .../0006-rdar20588474.swift | 14 ++-- .../0010-rdar20638881.swift | 12 +-- .../0013-rdar19519590.swift | 4 +- .../0014-rdar20508671.swift | 6 +- .../0018-rdar21524144.swift | 4 +- .../0019-rdar21511651.swift | 14 ++-- .../0020-rdar21598514.swift | 4 +- .../0022-rdar21625478.swift | 8 +- .../0027-rdar21514140.swift | 14 ++-- validation-test/stdlib/Algorithm.swift | 4 +- validation-test/stdlib/ArrayNew.swift.gyb | 12 +-- .../stdlib/CollectionType.swift.gyb | 26 +++---- validation-test/stdlib/Dictionary.swift | 34 ++++----- validation-test/stdlib/SequenceType.swift.gyb | 20 ++--- validation-test/stdlib/Set.swift | 28 +++---- validation-test/stdlib/Unicode.swift | 24 +++--- validation-test/stdlib/UnicodeTrie.swift.gyb | 2 +- .../stdlib/UnicodeUTFEncoders.swift | 2 +- 93 files changed, 392 insertions(+), 392 deletions(-) diff --git a/docs/SequencesAndCollections.rst b/docs/SequencesAndCollections.rst index 9c3fc2cf004bd..93d4ff5c3e18d 100644 --- a/docs/SequencesAndCollections.rst +++ b/docs/SequencesAndCollections.rst @@ -37,7 +37,7 @@ represented by the `SequenceType` protocol:: protocol SequenceType { typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } .. sidebar:: Hiding Iterator Type Details @@ -68,8 +68,8 @@ the two kinds of sequences. …\ `in`, and thus require *separate traversal state*. To get an initial traversal state for an arbitrary sequence `x`, Swift -calls `x.generate()`. The sequence delivers that state, along with -traversal logic, in the form of a **iterator**. +calls `x.iterator()`. The sequence delivers that state, along with +traversal logic, in the form of an **iterator**. Iterators ========== @@ -160,10 +160,10 @@ end. For example:: withSeparator separator: S.Iterator.Element ) -> [S.Iterator.Element] { var result: [S.Iterator.Element] = [] - var g = source.generate() - if let start = g.next() { + var iterator = source.iterator() + if let start = iterator.next() { result.append(start) - while let next = g.next() { + while let next = iterator.next() { result.append(separator) result.append(next) } @@ -192,7 +192,7 @@ depend on stability that an arbitrary sequence can't provide: the elements it has yet to return from `next()`. Therefore, every iterator *could* satisfy the requirements of `SequenceType` by simply declaring conformance, and returning `self` from its - `generate()` method. In fact, if it weren't for `current language + `iterator()` method. In fact, if it weren't for `current language limitations `_, `IteratorProtocol` would refine `SequenceType`, as follows: diff --git a/docs/archive/LangRef.html b/docs/archive/LangRef.html index b52ed146d0dae..961fdf94fd3c2 100644 --- a/docs/archive/LangRef.html +++ b/docs/archive/LangRef.html @@ -626,7 +626,7 @@

'typealias' protocol elements (associated typ
     protocol SequenceType {
       typename Iterator : IteratorProtocol
-      func generate() -> Iterator
+      func iterator() -> Iterator
     }
   
diff --git a/docs/proposals/DeclarationTypeChecker.rst b/docs/proposals/DeclarationTypeChecker.rst index 6195f87e438c4..b775437a1426c 100644 --- a/docs/proposals/DeclarationTypeChecker.rst +++ b/docs/proposals/DeclarationTypeChecker.rst @@ -80,7 +80,7 @@ We can address this problem by restricting the language to disallow extensions v protocol SequenceType { typealias Element - mutating func generate() -> Element? + mutating func iterator() -> Element? } struct IntRangeGenerator : SequenceType { @@ -88,7 +88,7 @@ We can address this problem by restricting the language to disallow extensions v let limit: Int // infers SequenceType's Element == Int - mutating func generate() -> Int? { + mutating func iterator() -> Int? { if current == limit { return nil } return current++ } diff --git a/include/swift/AST/KnownIdentifiers.def b/include/swift/AST/KnownIdentifiers.def index e95a9bc562c18..f9b72250a9aab 100644 --- a/include/swift/AST/KnownIdentifiers.def +++ b/include/swift/AST/KnownIdentifiers.def @@ -36,9 +36,9 @@ IDENTIFIER(error) IDENTIFIER(forKeyedSubscript) IDENTIFIER(Foundation) IDENTIFIER(fromRaw) -IDENTIFIER(generate) IDENTIFIER(hashValue) IDENTIFIER(init) +IDENTIFIER(iterator) IDENTIFIER(Iterator) IDENTIFIER(load) IDENTIFIER(next) diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index 9d0c0e980e88a..4bc9553103f6a 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -599,7 +599,7 @@ class StmtChecker : public StmtVisitor { S->setSequence(sequence); } - // Invoke generate() to get a generator from the sequence. + // Invoke iterator() to get an iterator from the sequence. Type generatorTy; VarDecl *generator; { @@ -620,7 +620,7 @@ class StmtChecker : public StmtVisitor { Expr *getIterator = TC.callWitness(sequence, DC, sequenceProto, conformance, - TC.Context.Id_generate, + TC.Context.Id_iterator, {}, diag::sequence_protocol_broken); if (!getIterator) return nullptr; diff --git a/stdlib/private/StdlibUnittest/CheckCollectionType.swift b/stdlib/private/StdlibUnittest/CheckCollectionType.swift index b997fa9df6e3a..44a516d97f334 100644 --- a/stdlib/private/StdlibUnittest/CheckCollectionType.swift +++ b/stdlib/private/StdlibUnittest/CheckCollectionType.swift @@ -333,10 +333,10 @@ extension TestSuite { testNamePrefix += String(Collection.Type) //===----------------------------------------------------------------------===// -// generate() +// iterator() //===----------------------------------------------------------------------===// -self.test("\(testNamePrefix).generate()/semantics") { +self.test("\(testNamePrefix).iterator()/semantics") { for test in subscriptRangeTests { let c = makeWrappedCollection(test.collection) for _ in 0..<3 { diff --git a/stdlib/private/StdlibUnittest/LoggingWrappers.swift.gyb b/stdlib/private/StdlibUnittest/LoggingWrappers.swift.gyb index 9d5b88c2082f2..0d1f81439660e 100644 --- a/stdlib/private/StdlibUnittest/LoggingWrappers.swift.gyb +++ b/stdlib/private/StdlibUnittest/LoggingWrappers.swift.gyb @@ -226,8 +226,8 @@ public struct LoggingRangeReplaceableCollection< return try base.filter(includeElement) } - public func generate() -> Base.Iterator { - return base.generate() + public func iterator() -> Base.Iterator { + return base.iterator() } } @@ -447,9 +447,9 @@ public struct Logging${Kind} : ${Kind}Type, LoggingType { } % end - public func generate() -> LoggingIterator { + public func iterator() -> LoggingIterator { ++Log.generate[selfType] - return LoggingIterator(base.generate()) + return LoggingIterator(base.iterator()) } public func underestimateCount() -> Int { diff --git a/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb b/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb index 60e1c806ae4cc..6a0f09566898d 100644 --- a/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb +++ b/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb @@ -1918,7 +1918,7 @@ public func checkSequence< ) { let expectedCount: Int = numericCast(expected.count) checkIterator( - expected, sequence.generate(), ${trace}, + expected, sequence.iterator(), ${trace}, resiliencyChecks: resiliencyChecks, sameValue: sameValue) @@ -2476,7 +2476,7 @@ func compose(f: A -> B, _ g: B -> C) -> A -> C { } /// State that is created every time a fresh iterator is created with -/// `MinimalSequence.generate()`. +/// `MinimalSequence.iterator()`. internal class _MinimalIteratorPrivateState { internal init() {} @@ -2583,8 +2583,8 @@ extension StrictSequenceType { } extension StrictSequenceType where Iterator : _MinimalIteratorProtocol { - public func generate() -> MinimalIterator { - return base.generate() + public func iterator() -> MinimalIterator { + return base.iterator() } } @@ -2615,7 +2615,7 @@ public struct MinimalSequence : SequenceType, CustomDebugStringConvertible { } } - public func generate() -> MinimalIterator { + public func iterator() -> MinimalIterator { return MinimalIterator(_sharedState) } @@ -3332,8 +3332,8 @@ extension ${Protocol} { } extension ${Protocol} where Iterator : _MinimalIteratorProtocol { - public func generate() -> MinimalIterator { - return base.generate() + public func iterator() -> MinimalIterator { + return base.iterator() } } @@ -3386,7 +3386,7 @@ public struct ${Self} : ${'MutableCollectionType' if mutable else 'Collection } } - public func generate() -> MinimalIterator { + public func iterator() -> MinimalIterator { return MinimalIterator(_elements) } @@ -3461,8 +3461,8 @@ extension ${Protocol} { } extension ${Protocol} where Iterator : _MinimalIteratorProtocol { - public func generate() -> MinimalIterator { - return base.generate() + public func iterator() -> MinimalIterator { + return base.iterator() } } @@ -3531,7 +3531,7 @@ public struct ${Self} : RangeReplaceableCollectionType { _CollectionState(newRootStateForElementCount: self.elements.count) } - public func generate() -> MinimalIterator { + public func iterator() -> MinimalIterator { return MinimalIterator(elements) } @@ -3917,7 +3917,7 @@ public struct Defaulted${traversal}RangeReplaceableSlice base: Base(elements: elements)) } - public func generate() -> MinimalIterator { + public func iterator() -> MinimalIterator { return MinimalIterator(Array(self)) } diff --git a/stdlib/public/SDK/Foundation/Foundation.swift b/stdlib/public/SDK/Foundation/Foundation.swift index 8b68711dad51b..d76d3c2849378 100644 --- a/stdlib/public/SDK/Foundation/Foundation.swift +++ b/stdlib/public/SDK/Foundation/Foundation.swift @@ -725,7 +725,7 @@ extension NSArray : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - final public func generate() -> NSFastEnumerationIterator { + final public func iterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(self) } } @@ -769,7 +769,7 @@ extension NSSet : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> NSFastEnumerationIterator { + public func iterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(self) } } @@ -778,7 +778,7 @@ extension NSOrderedSet : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> NSFastEnumerationIterator { + public func iterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(self) } } @@ -816,7 +816,7 @@ extension NSIndexSet : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> NSIndexSetIterator { + public func iterator() -> NSIndexSetIterator { return NSIndexSetIterator(set: self) } } @@ -942,7 +942,7 @@ extension NSDictionary : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> Iterator { + public func iterator() -> Iterator { return Iterator(self) } } @@ -951,7 +951,7 @@ extension NSEnumerator : SequenceType { /// Return an *iterator* over the *enumerator*. /// /// - Complexity: O(1). - public func generate() -> NSFastEnumerationIterator { + public func iterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(self) } } diff --git a/stdlib/public/core/Algorithm.swift b/stdlib/public/core/Algorithm.swift index bb3bc7f1b97da..e8329822dbbb0 100644 --- a/stdlib/public/core/Algorithm.swift +++ b/stdlib/public/core/Algorithm.swift @@ -71,10 +71,10 @@ public func max(x: T, _ y: T, _ z: T, _ rest: T...) -> T { /// starting at zero, along with the elements of the underlying /// `Base`: /// -/// var g = EnumeratedIterator(["foo", "bar"].generate()) -/// g.next() // (0, "foo") -/// g.next() // (1, "bar") -/// g.next() // nil +/// var iterator = ["foo", "bar"].enumerate() +/// iterator.next() // (0, "foo") +/// iterator.next() // (1, "bar") +/// iterator.next() // nil /// /// - Note: Idiomatic usage is to call `enumerate` instead of /// constructing an `EnumeratedIterator` directly. @@ -123,8 +123,8 @@ public struct EnumeratedSequence : SequenceType { /// Returns an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> EnumeratedIterator { - return EnumeratedIterator(_base: _base.generate()) + public func iterator() -> EnumeratedIterator { + return EnumeratedIterator(_base: _base.iterator()) } } diff --git a/stdlib/public/core/Arrays.swift.gyb b/stdlib/public/core/Arrays.swift.gyb index 6ea7bb4e74c91..bf5e1cc5cabe8 100644 --- a/stdlib/public/core/Arrays.swift.gyb +++ b/stdlib/public/core/Arrays.swift.gyb @@ -1216,7 +1216,7 @@ internal func _arrayAppendSequence< >( inout buffer: Buffer, _ newItems: S ) { - var stream = newItems.generate() + var stream = newItems.iterator() var nextItem = stream.next() if nextItem == nil { @@ -1262,8 +1262,8 @@ public func == ( return true } - var streamLHS = lhs.generate() - var streamRHS = rhs.generate() + var streamLHS = lhs.iterator() + var streamRHS = rhs.iterator() var nextLHS = streamLHS.next() while nextLHS != nil { diff --git a/stdlib/public/core/Character.swift b/stdlib/public/core/Character.swift index 5633bf68dc2a1..312f58e0bdcc1 100644 --- a/stdlib/public/core/Character.swift +++ b/stdlib/public/core/Character.swift @@ -188,7 +188,7 @@ public struct Character : internal var _data: UInt64 } - internal func generate() -> Iterator { + internal func iterator() -> Iterator { return Iterator(data) } @@ -199,7 +199,7 @@ public struct Character : struct _SmallUTF16 : CollectionType { init(_ u8: UInt64) { let count = UTF16.measure( - UTF8.self, input: _SmallUTF8(u8).generate(), + UTF8.self, input: _SmallUTF8(u8).iterator(), repairIllFormedSequences: true)!.0 _sanityCheck(count <= 4, "Character with more than 4 UTF-16 code units") self.count = UInt16(count) @@ -209,7 +209,7 @@ public struct Character : u16 = u16 | UInt64($0) } transcode( - UTF8.self, UTF16.self, _SmallUTF8(u8).generate(), output, + UTF8.self, UTF16.self, _SmallUTF8(u8).iterator(), output, stopOnError: false) self.data = u16 } diff --git a/stdlib/public/core/Collection.swift b/stdlib/public/core/Collection.swift index 35b154a513081..ff6a15a2cbcf0 100644 --- a/stdlib/public/core/Collection.swift +++ b/stdlib/public/core/Collection.swift @@ -73,12 +73,12 @@ public protocol MutableIndexable { /// An *iterator* for an arbitrary *collection*. Provided `C` /// conforms to the other requirements of `Indexable`, /// `IndexingGenerator` can be used as the result of `C`'s -/// `generate()` method. For example: +/// `iterator()` method. For example: /// /// struct MyCollection : CollectionType { /// struct Index : ForwardIndexType { /* implementation hidden */ } /// subscript(i: Index) -> MyElement { /* implementation hidden */ } -/// func generate() -> IndexingGenerator { // <=== +/// func iterator() -> IndexingGenerator { // <=== /// return IndexingGenerator(self) /// } /// } @@ -128,9 +128,9 @@ public protocol CollectionType : Indexable, SequenceType { typealias Iterator : IteratorProtocol = IndexingGenerator // FIXME: Needed here so that the Iterator is properly deduced from - // a custom generate() function. Otherwise we get an + // a custom iterator() function. Otherwise we get an // IndexingGenerator. - func generate() -> Iterator + func iterator() -> Iterator // FIXME: should be constrained to CollectionType // ( Implement recursive protocol @@ -195,11 +195,11 @@ public protocol CollectionType : Indexable, SequenceType { var first: Iterator.Element? { get } } -/// Supply the default `generate()` method for `CollectionType` models +/// Supply the default `iterator()` method for `CollectionType` models /// that accept the default associated `Iterator`, /// `IndexingGenerator`. extension CollectionType where Iterator == IndexingGenerator { - public func generate() -> IndexingGenerator { + public func iterator() -> IndexingGenerator { return IndexingGenerator(self) } } @@ -739,7 +739,7 @@ public struct PermutationGenerator< /// - Requires: `elements[i]` is valid for every `i` in `indices`. public init(elements: C, indices: Indices) { self.seq = elements - self.indices = indices.generate() + self.indices = indices.iterator() } } diff --git a/stdlib/public/core/CollectionOfOne.swift b/stdlib/public/core/CollectionOfOne.swift index efd8eda12a1ce..41a908f4c5cf3 100644 --- a/stdlib/public/core/CollectionOfOne.swift +++ b/stdlib/public/core/CollectionOfOne.swift @@ -61,7 +61,7 @@ public struct CollectionOfOne : CollectionType { /// Return a *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> IteratorOfOne { + public func iterator() -> IteratorOfOne { return IteratorOfOne(element) } diff --git a/stdlib/public/core/ContiguousArrayBuffer.swift b/stdlib/public/core/ContiguousArrayBuffer.swift index a6a305f241e37..ff63611119710 100644 --- a/stdlib/public/core/ContiguousArrayBuffer.swift +++ b/stdlib/public/core/ContiguousArrayBuffer.swift @@ -555,7 +555,7 @@ internal func _copySequenceToNativeArrayBuffer< _UnsafePartiallyInitializedContiguousArrayBuffer( initialCapacity: initialCapacity) - var iterator = source.generate() + var iterator = source.iterator() // FIXME(performance): use _initializeTo(). diff --git a/stdlib/public/core/EmptyCollection.swift b/stdlib/public/core/EmptyCollection.swift index eca659bd70fc7..c83343bea9454 100644 --- a/stdlib/public/core/EmptyCollection.swift +++ b/stdlib/public/core/EmptyCollection.swift @@ -54,7 +54,7 @@ public struct EmptyCollection : CollectionType { /// Returns an empty *iterator*. /// /// - Complexity: O(1). - public func generate() -> EmptyIterator { + public func iterator() -> EmptyIterator { return EmptyIterator() } diff --git a/stdlib/public/core/Existential.swift b/stdlib/public/core/Existential.swift index 79f664bd5c7d1..058537dc0ea7b 100644 --- a/stdlib/public/core/Existential.swift +++ b/stdlib/public/core/Existential.swift @@ -31,7 +31,7 @@ internal struct _CollectionOf< /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - func generate() -> AnyIterator { + func iterator() -> AnyIterator { var index = startIndex return AnyIterator { () -> T? in diff --git a/stdlib/public/core/ExistentialCollection.swift.gyb b/stdlib/public/core/ExistentialCollection.swift.gyb index 2f422d47be6a7..045d23a17e46a 100644 --- a/stdlib/public/core/ExistentialCollection.swift.gyb +++ b/stdlib/public/core/ExistentialCollection.swift.gyb @@ -42,7 +42,7 @@ public struct AnyIterator : IteratorProtocol { /// // This is a really complicated type of no interest to our /// // clients. /// let g: MapSequenceIterator, String> - /// = lazyStrings.generate() + /// = lazyStrings.iterator() /// return AnyIterator(g) /// } public init(_ base: I) { @@ -115,7 +115,7 @@ internal func _typeID(instance: AnyObject) -> ObjectIdentifier { //===----------------------------------------------------------------------===// internal class _AnySequenceBox { - internal func generate() -> AnyIterator { _abstract() } + internal func iterator() -> AnyIterator { _abstract() } internal func _underestimateCount() -> Int { _abstract() } @@ -145,8 +145,8 @@ internal class _${Kind}Box : _Any${Kind}Box { typealias Element = S.Iterator.Element - override func generate() -> AnyIterator { - return AnyIterator(_base.generate()) + override func iterator() -> AnyIterator { + return AnyIterator(_base.iterator()) } override func _underestimateCount() -> Int { return _base.underestimateCount() @@ -192,7 +192,7 @@ internal struct _ClosureBasedSequence self._makeUnderlyingIterator = makeUnderlyingIterator } - internal func generate() -> Iterator { + internal func iterator() -> Iterator { return _makeUnderlyingIterator() } @@ -212,7 +212,7 @@ public struct AnySequence : SequenceType { _box = _SequenceBox(base) } - /// Create a sequence whose `generate()` method forwards to + /// Create a sequence whose `iterator()` method forwards to /// `makeUnderlyingIterator`. public init( _ makeUnderlyingIterator: () -> I @@ -223,8 +223,8 @@ public struct AnySequence : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> AnyIterator { - return _box.generate() + public func iterator() -> AnyIterator { + return _box.iterator() } internal let _box: _AnySequenceBox @@ -581,8 +581,8 @@ public struct Any${Traversal}Collection : AnyCollectionType { /// Returns an *iterator* over the elements of this *collection*. /// /// - Complexity: O(1). - public func generate() -> AnyIterator { - return _box.generate() + public func iterator() -> AnyIterator { + return _box.iterator() } /// The position of the first element in a non-empty collection. diff --git a/stdlib/public/core/Filter.swift b/stdlib/public/core/Filter.swift index 810a9ca144b2f..8188ce92acebe 100644 --- a/stdlib/public/core/Filter.swift +++ b/stdlib/public/core/Filter.swift @@ -65,9 +65,9 @@ public struct LazyFilterSequence /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> LazyFilterIterator { + public func iterator() -> LazyFilterIterator { return LazyFilterIterator( - base.generate(), whereElementsSatisfy: _include) + base.iterator(), whereElementsSatisfy: _include) } /// Creates an instance consisting of the elements `x` of `base` for @@ -213,9 +213,9 @@ public struct LazyFilterCollection< /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> LazyFilterIterator { + public func iterator() -> LazyFilterIterator { return LazyFilterIterator( - _base.generate(), whereElementsSatisfy: _predicate) + _base.iterator(), whereElementsSatisfy: _predicate) } var _base: Base diff --git a/stdlib/public/core/Flatten.swift.gyb b/stdlib/public/core/Flatten.swift.gyb index 6146365bdbaa5..a9a56c580f95a 100644 --- a/stdlib/public/core/Flatten.swift.gyb +++ b/stdlib/public/core/Flatten.swift.gyb @@ -45,7 +45,7 @@ public struct FlattenIterator< if _slowPath(s == nil) { return nil } - _inner = s!.generate() + _inner = s!.iterator() } while true } @@ -83,8 +83,8 @@ public struct FlattenSequence< /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> FlattenIterator { - return FlattenIterator(_base.generate()) + public func iterator() -> FlattenIterator { + return FlattenIterator(_base.iterator()) } internal var _base: Base @@ -240,8 +240,8 @@ public struct ${Collection}< /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> FlattenIterator { - return FlattenIterator(_base.generate()) + public func iterator() -> FlattenIterator { + return FlattenIterator(_base.iterator()) } /// The position of the first element in a non-empty collection. diff --git a/stdlib/public/core/HashedCollections.swift.gyb b/stdlib/public/core/HashedCollections.swift.gyb index 9a7d590002aee..52ff0f8ad5942 100644 --- a/stdlib/public/core/HashedCollections.swift.gyb +++ b/stdlib/public/core/HashedCollections.swift.gyb @@ -414,8 +414,8 @@ public struct Set : /// Return a *iterator* over the members. /// /// - Complexity: O(1). - public func generate() -> SetIterator { - return _variantStorage.generate() + public func iterator() -> SetIterator { + return _variantStorage.iterator() } // @@ -650,7 +650,7 @@ public struct Set : } /// The first element obtained when iterating, or `nil` if `self` is - /// empty. Equivalent to `self.generate().next()`. + /// empty. Equivalent to `self.iterator().next()`. public var first: Element? { return count > 0 ? self[startIndex] : .None } @@ -1122,8 +1122,8 @@ public struct Dictionary : /// Return a *iterator* over the (key, value) pairs. /// /// - Complexity: O(1). - public func generate() -> DictionaryIterator { - return _variantStorage.generate() + public func iterator() -> DictionaryIterator { + return _variantStorage.iterator() } // @@ -3454,7 +3454,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType { /// Return a *iterator* over the (Key, Value) pairs. /// /// - Complexity: O(1). - internal func generate() -> ${Self}Iterator<${TypeParameters}> { + internal func iterator() -> ${Self}Iterator<${TypeParameters}> { switch self { case .Native(let owner): return diff --git a/stdlib/public/core/Join.swift b/stdlib/public/core/Join.swift index aa0aa22a82b1c..5d83a72e901e8 100644 --- a/stdlib/public/core/Join.swift +++ b/stdlib/public/core/Join.swift @@ -43,7 +43,7 @@ public struct JoinIterator< switch _state { case .Start: if let nextSubSequence = _base.next() { - _inner = nextSubSequence.generate() + _inner = nextSubSequence.iterator() _state = .GeneratingElements } else { _state = .End @@ -56,18 +56,18 @@ public struct JoinIterator< return result } if _separatorData.isEmpty { - _inner = _base.next()?.generate() + _inner = _base.next()?.iterator() if _inner == nil { _state = .End return nil } } else { - _inner = _base.next()?.generate() + _inner = _base.next()?.iterator() if _inner == nil { _state = .End return nil } - _separator = _separatorData.generate() + _separator = _separatorData.iterator() _state = .GeneratingSeparator } @@ -116,9 +116,9 @@ public struct JoinSequence< /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> JoinIterator { + public func iterator() -> JoinIterator { return JoinIterator( - base: _base.generate(), + base: _base.iterator(), separator: _separator) } @@ -141,7 +141,7 @@ public struct JoinSequence< } if separatorSize != 0 { - var gen = _base.generate() + var gen = _base.iterator() if let first = gen.next() { result.appendContentsOf(first) while let next = gen.next() { diff --git a/stdlib/public/core/LazyCollection.swift b/stdlib/public/core/LazyCollection.swift index e22db738fe3b5..eafc9e6a90442 100644 --- a/stdlib/public/core/LazyCollection.swift +++ b/stdlib/public/core/LazyCollection.swift @@ -74,7 +74,7 @@ extension LazyCollection : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> Base.Iterator { return _base.generate() } + public func iterator() -> Base.Iterator { return _base.iterator() } /// Return a value less than or equal to the number of elements in /// `self`, **nondestructively**. diff --git a/stdlib/public/core/LazySequence.swift b/stdlib/public/core/LazySequence.swift index fef3ad69fb4ca..f9e3483d4f7c0 100644 --- a/stdlib/public/core/LazySequence.swift +++ b/stdlib/public/core/LazySequence.swift @@ -76,9 +76,9 @@ /// struct LazyScanSequence /// : LazySequenceType // Chained operations on self are lazy, too /// { -/// func generate() -> LazyScanIterator { +/// func iterator() -> LazyScanIterator { /// return LazyScanIterator( -/// nextElement: initial, base: base.generate(), combine: combine) +/// nextElement: initial, base: base.iterator(), combine: combine) /// } /// private let initial: ResultElement /// private let base: Base diff --git a/stdlib/public/core/Map.swift b/stdlib/public/core/Map.swift index 133ad084b64ea..e6c1aab89b7d3 100644 --- a/stdlib/public/core/Map.swift +++ b/stdlib/public/core/Map.swift @@ -44,8 +44,8 @@ public struct LazyMapSequence /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> LazyMapIterator { - return LazyMapIterator(_base: _base.generate(), _transform: _transform) + public func iterator() -> LazyMapIterator { + return LazyMapIterator(_base: _base.iterator(), _transform: _transform) } /// Return a value less than or equal to the number of elements in @@ -99,8 +99,8 @@ public struct LazyMapCollection /// Returns an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> LazyMapIterator { - return LazyMapIterator(_base: _base.generate(), _transform: _transform) + public func iterator() -> LazyMapIterator { + return LazyMapIterator(_base: _base.iterator(), _transform: _transform) } public func underestimateCount() -> Int { diff --git a/stdlib/public/core/Range.swift b/stdlib/public/core/Range.swift index d08f1d1130bd9..c40ebcba1a2c5 100644 --- a/stdlib/public/core/Range.swift +++ b/stdlib/public/core/Range.swift @@ -114,7 +114,7 @@ public struct Range< /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> RangeIterator { + public func iterator() -> RangeIterator { return RangeIterator(self) } diff --git a/stdlib/public/core/Sequence.swift b/stdlib/public/core/Sequence.swift index 6e85e31b65aa4..d112ee415fa1e 100644 --- a/stdlib/public/core/Sequence.swift +++ b/stdlib/public/core/Sequence.swift @@ -21,7 +21,7 @@ /// specific *sequence* is multi-pass, either because its concrete /// type is known or because it is constrained to `CollectionType`. /// Also, the iterators must be obtained by distinct calls to the -/// *sequence's* `generate()` method, rather than by copying. +/// *sequence's* `iterator()` method, rather than by copying. public protocol IteratorProtocol { /// The type of element traversed by `self`. typealias Element @@ -78,7 +78,7 @@ public protocol SequenceType { /// /// - Complexity: O(1). @warn_unused_result - func generate() -> Iterator + func iterator() -> Iterator /// Return a value less than or equal to the number of elements in /// `self`, **nondestructively**. @@ -201,11 +201,11 @@ public protocol SequenceType { -> UnsafeMutablePointer } -/// A default generate() function for `IteratorProtocol` instances that +/// A default iterator() function for `IteratorProtocol` instances that /// are declared to conform to `SequenceType` extension SequenceType where Self.Iterator == Self, Self : IteratorProtocol { - public func generate() -> Self { + public func iterator() -> Self { return self } } @@ -220,29 +220,29 @@ extension SequenceType internal class _DropFirstSequence : SequenceType, IteratorProtocol { - internal var iterator: Base - internal let limit: Int - internal var dropped: Int + internal var _iterator: Base + internal let _limit: Int + internal var _dropped: Int internal init(_ iterator: Base, limit: Int, dropped: Int = 0) { - self.iterator = iterator - self.limit = limit - self.dropped = dropped + self._iterator = iterator + self._limit = limit + self._dropped = dropped } - internal func generate() -> _DropFirstSequence { + internal func iterator() -> _DropFirstSequence { return self } internal func next() -> Base.Element? { - while dropped < limit { - if iterator.next() == nil { - dropped = limit + while _dropped < _limit { + if _iterator.next() == nil { + _dropped = _limit return nil } - ++dropped + ++_dropped } - return iterator.next() + return _iterator.next() } } @@ -256,29 +256,29 @@ internal class _DropFirstSequence internal class _PrefixSequence : SequenceType, IteratorProtocol { - internal let maxLength: Int - internal var iterator: Base - internal var taken: Int + internal let _maxLength: Int + internal var _iterator: Base + internal var _taken: Int internal init(_ iterator: Base, maxLength: Int, taken: Int = 0) { - self.iterator = iterator - self.maxLength = maxLength - self.taken = taken + self._iterator = iterator + self._maxLength = maxLength + self._taken = taken } - internal func generate() -> _PrefixSequence { + internal func iterator() -> _PrefixSequence { return self } internal func next() -> Base.Element? { - if taken >= maxLength { return nil } - ++taken + if _taken >= _maxLength { return nil } + ++_taken - if let next = iterator.next() { + if let next = _iterator.next() { return next } - taken = maxLength + _taken = _maxLength return nil } } @@ -300,7 +300,7 @@ extension SequenceType { var result = ContiguousArray() result.reserveCapacity(initialCapacity) - var iterator = generate() + var iterator = self.iterator() // Add elements up to the initial capacity without checking for regrowth. for _ in 0..() - var iterator = generate() + var iterator = self.iterator() while let element = iterator.next() { if try includeElement(element) { @@ -351,12 +351,12 @@ extension SequenceType { if let any = self as? AnySequence, let box = any._box as? _SequenceBox<_DropFirstSequence> { let base = box._base - let folded = _DropFirstSequence(base.iterator, limit: base.limit + n, - dropped: base.dropped) + let folded = _DropFirstSequence( + base._iterator, limit: base._limit + n, dropped: base._dropped) return AnySequence(folded) } - return AnySequence(_DropFirstSequence(generate(), limit: n)) + return AnySequence(_DropFirstSequence(iterator(), limit: n)) } /// Returns a subsequence containing all but the last `n` elements. @@ -402,12 +402,12 @@ extension SequenceType { let box = any._box as? _SequenceBox<_PrefixSequence> { let base = box._base let folded = _PrefixSequence( - base.iterator, - maxLength: min(base.maxLength, maxLength), - taken: base.taken) + base._iterator, + maxLength: min(base._maxLength, maxLength), + taken: base._taken) return AnySequence(folded) } - return AnySequence(_PrefixSequence(generate(), maxLength: maxLength)) + return AnySequence(_PrefixSequence(iterator(), maxLength: maxLength)) } @warn_unused_result @@ -483,7 +483,7 @@ extension SequenceType { } var hitEnd = false - var iterator = self.generate() + var iterator = self.iterator() while true { guard let element = iterator.next() else { hitEnd = true @@ -606,7 +606,7 @@ extension SequenceType { public func _initializeTo(ptr: UnsafeMutablePointer) -> UnsafeMutablePointer { var p = UnsafeMutablePointer(ptr) - for x in IteratorSequence(self.generate()) { + for x in IteratorSequence(self.iterator()) { p++.initialize(x) } return p diff --git a/stdlib/public/core/SequenceAlgorithms.swift.gyb b/stdlib/public/core/SequenceAlgorithms.swift.gyb index d4a7d0f440f6a..5a374cdb73444 100644 --- a/stdlib/public/core/SequenceAlgorithms.swift.gyb +++ b/stdlib/public/core/SequenceAlgorithms.swift.gyb @@ -75,7 +75,7 @@ extension SequenceType ${"" if preds else "where Iterator.Element : Comparable"} % end ) ${rethrows_}-> ${GElement}? { var minResult: ${GElement}? = nil - for e in IteratorSequence(generate()) { + for e in IteratorSequence(iterator()) { if let currentMinResult = minResult { % if preds: if try isOrderedBefore(e, currentMinResult) { minResult = e } @@ -100,7 +100,7 @@ extension SequenceType ${"" if preds else "where Iterator.Element : Comparable"} % end ) ${rethrows_}-> ${GElement}? { var maxResult: ${GElement}? = nil - for e in IteratorSequence(generate()) { + for e in IteratorSequence(iterator()) { if let currentMaxResult = maxResult { % if preds: if try isOrderedBefore(currentMaxResult, e) { maxResult = e } @@ -154,7 +154,7 @@ else: @noescape isEquivalent: (${GElement}, ${GElement}) throws -> Bool % end ) ${rethrows_}-> Bool { - var otherIterator = other.generate() + var otherIterator = other.iterator() for e0 in self { if let e1 = otherIterator.next() { if ${"try !isEquivalent(e0, e1)" if preds else "e0 != e1"} { @@ -207,8 +207,8 @@ else: @noescape isEquivalent: (${GElement}, ${GElement}) throws -> Bool % end ) ${rethrows_}-> Bool { - var g1 = self.generate() - var g2 = other.generate() + var g1 = self.iterator() + var g2 = other.iterator() while true { switch (g1.next(), g2.next()) { case let (e1?, e2?): @@ -274,8 +274,8 @@ else: @noescape isOrderedBefore: (${GElement}, ${GElement}) throws -> Bool % end ) ${rethrows_}-> Bool { - var g1 = self.generate() - var g2 = other.generate() + var g1 = self.iterator() + var g2 = other.iterator() while true { if let e1 = g1.next() { if let e2 = g2.next() { diff --git a/stdlib/public/core/SequenceWrapper.swift b/stdlib/public/core/SequenceWrapper.swift index 802969a6627c1..bd93cba66a983 100644 --- a/stdlib/public/core/SequenceWrapper.swift +++ b/stdlib/public/core/SequenceWrapper.swift @@ -33,8 +33,8 @@ extension SequenceType /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> Base.Iterator { - return self._base.generate() + public func iterator() -> Base.Iterator { + return self._base.iterator() } public func underestimateCount() -> Int { diff --git a/stdlib/public/core/Stride.swift b/stdlib/public/core/Stride.swift index e23140ccf2ee8..503a7915f5ebb 100644 --- a/stdlib/public/core/Stride.swift +++ b/stdlib/public/core/Stride.swift @@ -145,7 +145,7 @@ public struct StrideTo : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> StrideToIterator { + public func iterator() -> StrideToIterator { return StrideToIterator(current: start, end: end, stride: stride) } @@ -206,7 +206,7 @@ public struct StrideThrough : SequenceType { /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> StrideThroughIterator { + public func iterator() -> StrideThroughIterator { return StrideThroughIterator( current: start, end: end, stride: stride, done: false) } diff --git a/stdlib/public/core/String.swift b/stdlib/public/core/String.swift index 1b4f4056dfaf0..30fd664e40233 100644 --- a/stdlib/public/core/String.swift +++ b/stdlib/public/core/String.swift @@ -634,7 +634,7 @@ extension SequenceType where Iterator.Element == String { } if separatorSize != 0 { - var gen = generate() + var gen = iterator() if let first = gen.next() { result.appendContentsOf(first) while let next = gen.next() { diff --git a/stdlib/public/core/StringBuffer.swift b/stdlib/public/core/StringBuffer.swift index 0261238e5a801..730ab12a1a689 100644 --- a/stdlib/public/core/StringBuffer.swift +++ b/stdlib/public/core/StringBuffer.swift @@ -91,7 +91,7 @@ public struct _StringBuffer { minimumCapacity: Int = 0 ) -> (_StringBuffer?, hadError: Bool) { // Determine how many UTF-16 code units we'll need - let inputStream = input.generate() + let inputStream = input.iterator() guard let (utf16Count, isAscii) = UTF16.measure(encoding, input: inputStream, repairIllFormedSequences: repairIllFormedSequences) else { return (.None, true) @@ -109,7 +109,7 @@ public struct _StringBuffer { (p++).memory = UTF8.CodeUnit($0) } let hadError = transcode( - encoding, UTF32.self, input.generate(), sink, + encoding, UTF32.self, input.iterator(), sink, stopOnError: true) _sanityCheck(!hadError, "string can not be ASCII if there were decoding errors") return (result, hadError) @@ -120,7 +120,7 @@ public struct _StringBuffer { (p++).memory = $0 } let hadError = transcode( - encoding, UTF16.self, input.generate(), sink, + encoding, UTF16.self, input.iterator(), sink, stopOnError: !repairIllFormedSequences) return (result, hadError) } diff --git a/stdlib/public/core/StringCore.swift b/stdlib/public/core/StringCore.swift index 901d3659b8c3d..ac78cd014369d 100644 --- a/stdlib/public/core/StringCore.swift +++ b/stdlib/public/core/StringCore.swift @@ -338,7 +338,7 @@ public struct _StringCore { UnsafeBufferPointer( start: UnsafeMutablePointer(_baseAddress), count: count - ).generate(), + ).iterator(), output, stopOnError: true ) @@ -678,7 +678,7 @@ extension _StringCore : RangeReplaceableCollectionType { } let growth = s.underestimateCount() - var g = s.generate() + var g = s.iterator() if _fastPath(growth > 0) { let newSize = count + growth diff --git a/stdlib/public/core/StringUnicodeScalarView.swift b/stdlib/public/core/StringUnicodeScalarView.swift index 461d080fb91eb..c3fe8455670b2 100644 --- a/stdlib/public/core/StringUnicodeScalarView.swift +++ b/stdlib/public/core/StringUnicodeScalarView.swift @@ -149,17 +149,17 @@ extension String { self._ascii = true self._asciiBase = UnsafeBufferPointer( start: UnsafePointer(_base._baseAddress), - count: _base.count).generate() + count: _base.count).iterator() } else { self._ascii = false self._base = UnsafeBufferPointer( start: UnsafePointer(_base._baseAddress), - count: _base.count).generate() + count: _base.count).iterator() } } else { self._ascii = false self._baseSet = false - self._iterator = _base.generate() + self._iterator = _base.iterator() } } @@ -206,7 +206,7 @@ extension String { /// /// - Complexity: O(1). @warn_unused_result - public func generate() -> Iterator { + public func iterator() -> Iterator { return Iterator(_core) } diff --git a/stdlib/public/core/UnsafeBufferPointer.swift.gyb b/stdlib/public/core/UnsafeBufferPointer.swift.gyb index 03f92462b49c9..938fb45fb7fef 100644 --- a/stdlib/public/core/UnsafeBufferPointer.swift.gyb +++ b/stdlib/public/core/UnsafeBufferPointer.swift.gyb @@ -76,7 +76,7 @@ public struct Unsafe${Mutable}BufferPointer /// Return a *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> UnsafeBufferPointerIterator { + public func iterator() -> UnsafeBufferPointerIterator { return UnsafeBufferPointerIterator(position: _position, end: _end) } diff --git a/stdlib/public/core/Zip.swift b/stdlib/public/core/Zip.swift index e3ba6f653f9e2..0f56a5cc1c7d4 100644 --- a/stdlib/public/core/Zip.swift +++ b/stdlib/public/core/Zip.swift @@ -87,10 +87,10 @@ public struct Zip2Sequence /// Return an *iterator* over the elements of this *sequence*. /// /// - Complexity: O(1). - public func generate() -> Iterator { + public func iterator() -> Iterator { return Iterator( - _sequences.0.generate(), - _sequences.1.generate()) + _sequences.0.iterator(), + _sequences.1.iterator()) } internal let _sequences: (Sequence1, Sequence2) diff --git a/test/1_stdlib/ArrayCore.swift b/test/1_stdlib/ArrayCore.swift index ae8759cce0cd8..88188b04edfa0 100644 --- a/test/1_stdlib/ArrayCore.swift +++ b/test/1_stdlib/ArrayCore.swift @@ -64,7 +64,7 @@ struct MrMcRange : CollectionType { self.base = base } - func generate() -> IndexingGenerator { + func iterator() -> IndexingGenerator { return IndexingGenerator(self) } @@ -103,7 +103,7 @@ print("testing...") func test() { //===--- Sequences can be converted -------------------------------------===// - let n0 = ((Tracked(10).. printSequence(n0) diff --git a/test/1_stdlib/Collection.swift b/test/1_stdlib/Collection.swift index 9f2555aa7e4eb..538184dcd9bca 100644 --- a/test/1_stdlib/Collection.swift +++ b/test/1_stdlib/Collection.swift @@ -15,7 +15,7 @@ struct X : CollectionType { } subscript(i: Index) -> Element { return msg[i] } - func generate() -> IndexingGenerator { + func iterator() -> IndexingGenerator { return IndexingGenerator(self) } } @@ -50,7 +50,7 @@ func isPalindrome0< var a = seq.indices var i = seq.indices var ir = i.lazy.reverse() - var b = ir.generate() + var b = ir.iterator() for i in a { if seq[i] != seq[b.next()!] { return false @@ -72,7 +72,7 @@ func isPalindrome1< >(seq: S) -> Bool { var a = PermutationGenerator(elements: seq, indices: seq.indices) - var b = seq.lazy.reverse().generate() + var b = seq.lazy.reverse().iterator() for nextChar in a { if nextChar != b.next()! { return false @@ -89,7 +89,7 @@ func isPalindrome1_5< S.Iterator.Element: Equatable >(seq: S) -> Bool { - var b = seq.lazy.reverse().generate() + var b = seq.lazy.reverse().iterator() for nextChar in seq { if nextChar != b.next()! { return false @@ -181,7 +181,7 @@ testCount() struct SequenceOnly : SequenceType { var base: T - func generate() -> T.Iterator { return base.generate() } + func iterator() -> T.Iterator { return base.iterator() } } func testUnderestimateCount() { diff --git a/test/1_stdlib/ExistentialCollection.swift b/test/1_stdlib/ExistentialCollection.swift index c9cb9287ae21f..1c6346a2c13cc 100644 --- a/test/1_stdlib/ExistentialCollection.swift +++ b/test/1_stdlib/ExistentialCollection.swift @@ -56,7 +56,7 @@ tests.test("AnyIterator") { // This is a really complicated type of no interest to our // clients. let iterator: LazyMapIterator, String> = - lazyStrings.generate() + lazyStrings.iterator() return AnyIterator(iterator) } expectEqual(["0", "1", "2", "3", "4"], Array(countStrings())) diff --git a/test/1_stdlib/Filter.swift b/test/1_stdlib/Filter.swift index 5d9519cd0357b..bfaf6a1e08c19 100644 --- a/test/1_stdlib/Filter.swift +++ b/test/1_stdlib/Filter.swift @@ -80,14 +80,14 @@ if true { // Test filtering Sequences if true { - let f0 = (0..<30).generate().lazy.filter { $0 % 7 == 0 } + let f0 = (0..<30).iterator().lazy.filter { $0 % 7 == 0 } // CHECK-NEXT: <0, 7, 14, 21, 28> printlnByGenerating(f0) // Also try when the first element of the underlying sequence // doesn't pass the filter - let f1 = (1..<30).generate().lazy.filter { $0 % 7 == 0 } + let f1 = (1..<30).iterator().lazy.filter { $0 % 7 == 0 } // CHECK-NEXT: <7, 14, 21, 28> printlnByGenerating(f1) diff --git a/test/1_stdlib/Generator.swift b/test/1_stdlib/Generator.swift index 5432bb511f5e6..74715797e504a 100644 --- a/test/1_stdlib/Generator.swift +++ b/test/1_stdlib/Generator.swift @@ -7,7 +7,7 @@ var tests = TestSuite("Iterator") // Check to make sure we are actually getting Optionals out of this // IteratorProtocol tests.test("Range") { - var w = (1..<2).generate() + var w = (1..<2).iterator() var maybe_one = w.next() expectType(Optional.self, &maybe_one) expectEqual(1, maybe_one) @@ -15,7 +15,7 @@ tests.test("Range") { } tests.test("RangeIteratorConformsToSequence") { - for x in (1..<2).generate() { + for x in (1..<2).iterator() { expectEqual(1, x) } } diff --git a/test/1_stdlib/Lazy.swift.gyb b/test/1_stdlib/Lazy.swift.gyb index 15a6ce1b79ca0..ecbbe89c23af0 100644 --- a/test/1_stdlib/Lazy.swift.gyb +++ b/test/1_stdlib/Lazy.swift.gyb @@ -204,8 +204,8 @@ struct SequenceWithCustomUnderestimateCount : SequenceType { self._data = MinimalSequence(elements: data.map(OpaqueValue.init)) } - func generate() -> MinimalSequence>.Iterator { - return _data.generate() + func iterator() -> MinimalSequence>.Iterator { + return _data.iterator() } func underestimateCount() -> Int { @@ -391,7 +391,7 @@ func expectSequencePassthrough< >(s: S, base: Base, arbitraryElement: S.Iterator.Element, count: Int) { let baseType = base.dynamicType - SequenceLog.generate.expectIncrement(baseType) { _ = s.generate() } + SequenceLog.generate.expectIncrement(baseType) { _ = s.iterator() } SequenceLog.underestimateCount.expectIncrement(baseType) { _ = s.underestimateCount() } @@ -519,7 +519,7 @@ tests.test("MapSequence/Passthrough") { } // Not exactly passthrough because we wrap the result CollectionLog.generate.expectIncrement(base.dynamicType) { - _ = mapped.generate() + _ = mapped.iterator() } } @@ -580,7 +580,7 @@ tests.test("LazyMapCollection/Passthrough") { } // Not exactly passthrough because we wrap the result CollectionLog.generate.expectIncrement(base.dynamicType) { - _ = mapped.generate() + _ = mapped.iterator() } } @@ -675,7 +675,7 @@ func checkFilterIteratorBase< S.Iterator == LazyFilterIterator, I.Element == OpaqueValue >(s1: S, _ s2: S) { - var g1 = s1.generate() + var g1 = s1.iterator() expectEqual(0, g1.next()!.value) expectEqual(2, g1.next()!.value) expectEqual(4, g1.next()!.value) @@ -684,7 +684,7 @@ func checkFilterIteratorBase< expectEqual(6, h1.next()!.value) expectEqual(7, h1.next()!.value) - var g2 = s2.generate() + var g2 = s2.iterator() expectEqual(1, g2.next()!.value) expectEqual(3, g2.next()!.value) expectEqual(5, g2.next()!.value) diff --git a/test/1_stdlib/Map.swift b/test/1_stdlib/Map.swift index 30296592b5b41..ac090e69c3773 100644 --- a/test/1_stdlib/Map.swift +++ b/test/1_stdlib/Map.swift @@ -42,7 +42,7 @@ let a = Array((2..<8).lazy.map { $0 * 3 }) print(a) // Test mapping a sequence -let s = a.generate().lazy.map { $0 / 3 } +let s = a.iterator().lazy.map { $0 / 3 } // CHECK-NEXT: <2, 3, 4, 5, 6, 7> print("<", terminator: "") var prefix = "" @@ -79,7 +79,7 @@ class Counter : IteratorProtocol { // A SequenceType with value semantics struct IntRange : SequenceType { - func generate() -> Counter { + func iterator() -> Counter { return Counter(start, end) } diff --git a/test/1_stdlib/NSSetAPI.swift b/test/1_stdlib/NSSetAPI.swift index ec7f6fa1e9923..62b55ab909c9d 100644 --- a/test/1_stdlib/NSSetAPI.swift +++ b/test/1_stdlib/NSSetAPI.swift @@ -76,14 +76,14 @@ NSIndexSetAPI.test("SequenceType") { let result = NSIndexSet() expectSequenceType(result) let s = NSIndexSet(indexesInRange: NSMakeRange(1, 1)) - var g = s.generate() + var g = s.iterator() // FIXME: Compiler doesn't accept these terms. // expectEqual(Optional.Some(1), g.next()) // expectEqual(Optional.None, g.next()) expectOptionalEqual(1, g.next()) expectEmpty(g.next()) let empty = NSIndexSet(indexesInRange: NSMakeRange(1, 0)) - var emptyGen = empty.generate() + var emptyGen = empty.iterator() expectEmpty(emptyGen.next()) } diff --git a/test/1_stdlib/SequenceWrapperTest.swift b/test/1_stdlib/SequenceWrapperTest.swift index da18bd8ac1e35..1baf5964ca9e5 100644 --- a/test/1_stdlib/SequenceWrapperTest.swift +++ b/test/1_stdlib/SequenceWrapperTest.swift @@ -49,7 +49,7 @@ func expectWrapperDispatch( sequenceWrapperTests.test("Dispatch/generate") { expectWrapperDispatch( - direct.generate(), indirect.generate(), dispatchLog.generate) + direct.iterator(), indirect.iterator(), dispatchLog.generate) } sequenceWrapperTests.test("Dispatch/underestimateCount") { diff --git a/test/1_stdlib/Sort.swift.gyb b/test/1_stdlib/Sort.swift.gyb index 74b2986baea3c..e9fd8082ec58b 100644 --- a/test/1_stdlib/Sort.swift.gyb +++ b/test/1_stdlib/Sort.swift.gyb @@ -68,7 +68,7 @@ class OffsetCollection : MutableCollectionType { get { return data[i - startIndex] } set { data[i - startIndex] = newValue } } - func generate() -> IndexingGenerator<[Int]> { + func iterator() -> IndexingGenerator<[Int]> { return IndexingGenerator<[Int]>(data) } func toArray() -> [Int] { diff --git a/test/Constraints/associated_self_types.swift b/test/Constraints/associated_self_types.swift index 39ed13f3c32a5..4a19bde4844bd 100644 --- a/test/Constraints/associated_self_types.swift +++ b/test/Constraints/associated_self_types.swift @@ -32,7 +32,7 @@ class X : Q { func f(x: SX) { } - func generate() -> No { + func iterator() -> No { return No() } } diff --git a/test/Constraints/invalid_constraint_lookup.swift b/test/Constraints/invalid_constraint_lookup.swift index ddd34f738654c..99b93d5c7f4ec 100644 --- a/test/Constraints/invalid_constraint_lookup.swift +++ b/test/Constraints/invalid_constraint_lookup.swift @@ -2,12 +2,12 @@ protocol P { typealias A - func generate() -> Int + func iterator() -> Int } func f(rhs: U) -> X { // expected-error {{use of undeclared type 'X'}} // FIXME: This diagnostic isn't great, it happens because the generic constraint // 'U' from the invalid type signature never gets resolved. - let g = rhs.generate() // expected-error {{type of expression is ambiguous without more context}} + let g = rhs.iterator() // expected-error {{type of expression is ambiguous without more context}} } struct Zzz { diff --git a/test/Constraints/nested_generics.swift b/test/Constraints/nested_generics.swift index 4b55972cb156c..bcf24c8fd6724 100644 --- a/test/Constraints/nested_generics.swift +++ b/test/Constraints/nested_generics.swift @@ -44,7 +44,7 @@ struct AnyStream { // Conform to the enumerable protocol. typealias Elements = StreamRange func getElements() -> Elements { - return Elements(index: 0, elements: input.generate()) + return Elements(index: 0, elements: input.iterator()) } } diff --git a/test/Constraints/recursive_concrete_constraints.swift b/test/Constraints/recursive_concrete_constraints.swift index 8e5b4030dd3b4..93b2dc32a4c78 100644 --- a/test/Constraints/recursive_concrete_constraints.swift +++ b/test/Constraints/recursive_concrete_constraints.swift @@ -21,7 +21,7 @@ struct S : CollectionType { return base[baseRange.startIndex + i] } - func generate() -> IndexingGenerator { + func iterator() -> IndexingGenerator { return IndexingGenerator(self) } diff --git a/test/Generics/associated_types.swift b/test/Generics/associated_types.swift index f03b1d4b6b1b5..99421bca31d84 100644 --- a/test/Generics/associated_types.swift +++ b/test/Generics/associated_types.swift @@ -111,7 +111,7 @@ struct zip func next() -> (A.Element, B.Element)? { } typealias Generator = zip - func generate() -> zip { } + func iterator() -> zip { } } protocol P8 { } diff --git a/test/Generics/deduction.swift b/test/Generics/deduction.swift index 66327c8f3b33d..0b1672efc00af 100644 --- a/test/Generics/deduction.swift +++ b/test/Generics/deduction.swift @@ -215,8 +215,8 @@ func rangeOfIsBefore< func callRangeOfIsBefore(ia: [Int], da: [Double]) { - rangeOfIsBefore(ia.generate()) - rangeOfIsBefore(da.generate()) // expected-error{{cannot invoke 'rangeOfIsBefore' with an argument list of type '(IndexingGenerator<[Double]>)'}} expected-note{{expected an argument list of type '(R)'}} + rangeOfIsBefore(ia.iterator()) + rangeOfIsBefore(da.iterator()) // expected-error{{cannot invoke 'rangeOfIsBefore' with an argument list of type '(IndexingGenerator<[Double]>)'}} expected-note{{expected an argument list of type '(R)'}} } //===----------------------------------------------------------------------===// diff --git a/test/Generics/function_defs.swift b/test/Generics/function_defs.swift index 19f2c6ad30ac9..065b9e90cb812 100644 --- a/test/Generics/function_defs.swift +++ b/test/Generics/function_defs.swift @@ -201,7 +201,7 @@ func conformanceViaRequires Element + func iterator() -> Element } protocol AcceptsAnElement { @@ -210,8 +210,8 @@ protocol AcceptsAnElement { } func impliedSameType(t: T) { - t.accept(t.generate()) - let e = t.generate(), e2 = t.generate() + t.accept(t.iterator()) + let e = t.iterator(), e2 = t.iterator() if e.isEqual(e2) || e.isLess(e2) { return } @@ -249,8 +249,8 @@ func recursiveSameType where T.MetaAssoc1 == V.Assoc1, V.Assoc1 == U.MetaAssoc2> (t: T, u: U) { - t.get().accept(t.get().generate()) - let e = t.get().generate(), e2 = t.get().generate() + t.get().accept(t.get().iterator()) + let e = t.get().iterator(), e2 = t.get().iterator() if e.isEqual(e2) || e.isLess(e2) { return } diff --git a/test/Generics/generic_types.swift b/test/Generics/generic_types.swift index 6a15f2ad598a5..7ea88424e35c7 100644 --- a/test/Generics/generic_types.swift +++ b/test/Generics/generic_types.swift @@ -72,7 +72,7 @@ func getFirst(r: R) -> R.Element { } func testGetFirst(ir: Range) { - _ = getFirst(ir.generate()) as Int + _ = getFirst(ir.iterator()) as Int } struct XT { @@ -159,7 +159,7 @@ struct SequenceY : SequenceType, IteratorProtocol { typealias Element = Y func next() -> Element? { return Y() } - func generate() -> Iterator { return self } + func iterator() -> Iterator { return self } } func useRangeOfPrintables(roi : RangeOfPrintables<[Int]>) { diff --git a/test/Generics/same_type_constraints.swift b/test/Generics/same_type_constraints.swift index efe0dd47a33bb..bd1080c421c4b 100644 --- a/test/Generics/same_type_constraints.swift +++ b/test/Generics/same_type_constraints.swift @@ -71,7 +71,7 @@ public struct GeneratorOf : IteratorProtocol, SequenceType { /// `GeneratorOf` is also a `SequenceType`, so it `generate`\ s /// a copy of itself - public func generate() -> GeneratorOf { + public func iterator() -> GeneratorOf { return self } let _next: ()->T? @@ -79,7 +79,7 @@ public struct GeneratorOf : IteratorProtocol, SequenceType { // rdar://problem/19009056 public struct LazySequenceOf : SequenceType { - public func generate() -> GeneratorOf { + public func iterator() -> GeneratorOf { return GeneratorOf({ return nil }) } public subscript(i : A) -> A { return i } @@ -91,7 +91,7 @@ public func iterate(f : A -> A)(x : A) -> LazySequenceOf, A>? { // public final class Iterate : SequenceType { typealias IteratorProtocol = IterateGenerator - public func generate() -> IterateGenerator { + public func iterator() -> IterateGenerator { return IterateGenerator() } } @@ -219,9 +219,9 @@ func GGWrap, s: ArraySlice<(Int,Int)>) { - GGWrap(a.generate(), s.generate()) - TTGenWrap(a.generate()) - IntIntGenWrap(s.generate()) + GGWrap(a.iterator(), s.iterator()) + TTGenWrap(a.iterator()) + IntIntGenWrap(s.iterator()) } // rdar://problem/20256475 diff --git a/test/IDE/Inputs/dumped_api.swift b/test/IDE/Inputs/dumped_api.swift index 42357df60f088..21e517f6f6ea9 100644 --- a/test/IDE/Inputs/dumped_api.swift +++ b/test/IDE/Inputs/dumped_api.swift @@ -57,7 +57,7 @@ public class AnyIterator : _AnyIteratorBase, GeneratorType { /// traversing the sequence consumes the generator. extension AnyIterator : SequenceType { /// Returns `self`. - public func generate() -> AnyIterator + public func iterator() -> AnyIterator } /// Return a `GeneratorType` instance that wraps `base` but whose type @@ -71,7 +71,7 @@ extension AnyIterator : SequenceType { /// // This is a really complicated type of no interest to our /// // clients. /// let g: MapSequenceGenerator, String> -/// = lazyStrings.generate() +/// = lazyStrings.iterator() /// return anyIterator(g) /// } public func anyIterator(base: G) -> AnyIterator @@ -112,7 +112,7 @@ public struct AnySequence : SequenceType { /// Return a *generator* over the elements of this *sequence*. /// /// Complexity: O(1) - public func generate() -> AnyIterator + public func iterator() -> AnyIterator } @@ -414,7 +414,7 @@ public struct AnyForwardCollection : AnyCollectionType { /// Return a *generator* over the elements of this *collection*. /// /// Complexity: O(1) - public func generate() -> AnyIterator + public func iterator() -> AnyIterator /// The position of the first element in a non-empty collection. /// @@ -492,7 +492,7 @@ public struct AnyBidirectionalCollection : AnyCollectionType { /// Return a *generator* over the elements of this *collection*. /// /// Complexity: O(1) - public func generate() -> AnyIterator + public func iterator() -> AnyIterator /// The position of the first element in a non-empty collection. /// @@ -561,7 +561,7 @@ public struct AnyRandomAccessCollection : AnyCollectionType { /// Return a *generator* over the elements of this *collection*. /// /// Complexity: O(1) - public func generate() -> AnyIterator + public func iterator() -> AnyIterator /// The position of the first element in a non-empty collection. /// diff --git a/test/IDE/complete_from_stdlib.swift b/test/IDE/complete_from_stdlib.swift index 61c7d4070a45e..b804891cc5f98 100644 --- a/test/IDE/complete_from_stdlib.swift +++ b/test/IDE/complete_from_stdlib.swift @@ -123,7 +123,7 @@ func testArchetypeReplacement1(a: [FOO]) { // PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/CurrNominal: append({#(newElement): Equatable#})[#Void#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/CurrNominal: insert({#(newElement): Equatable#}, {#atIndex: Int#})[#Void#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/CurrNominal: popLast()[#Equatable?#]{{; name=.+}} -// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/Super: generate()[#IndexingGenerator<[Equatable]>#]{{; name=.+}} +// PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/Super: iterator()[#IndexingGenerator<[Equatable]>#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceVar]/Super: isEmpty[#Bool#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceVar]/Super: first[#Equatable?#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_5-DAG: Decl[InstanceMethod]/Super: dropFirst({#(n): Int#})[#ArraySlice#]{{; name=.+}} diff --git a/test/IDE/dump_api.swift b/test/IDE/dump_api.swift index b2a9cf099d9b4..57b70f156062b 100644 --- a/test/IDE/dump_api.swift +++ b/test/IDE/dump_api.swift @@ -72,7 +72,7 @@ public class AnyIterator : _AnyIteratorBase, GeneratorType { /// traversing the sequence consumes the generator. extension AnyIterator : SequenceType { /// Returns `self`. - public func generate() -> AnyIterator { return self } + public func iterator() -> AnyIterator { return self } } /// Return a `GeneratorType` instance that wraps `base` but whose type @@ -86,7 +86,7 @@ extension AnyIterator : SequenceType { /// // This is a really complicated type of no interest to our /// // clients. /// let g: MapSequenceGenerator, String> -/// = lazyStrings.generate() +/// = lazyStrings.iterator() /// return anyIterator(g) /// } public func anyIterator(base: G) -> AnyIterator { @@ -131,7 +131,7 @@ internal func _typeID(instance: AnyObject) -> ObjectIdentifier { internal class _AnySequenceBox { // FIXME: can't make _AnySequenceBox generic and return // _AnyIterator here due to - func generate() -> _AnyIteratorBase {_abstract()} + func iterator() -> _AnyIteratorBase {_abstract()} func _underestimateCount() -> Int {_abstract()} // FIXME: can't traffic in UnsafeMutablePointer and @@ -154,8 +154,8 @@ internal class _SequenceBox : _AnySequenceBox { typealias Element = S.Generator.Element - override func generate() -> _AnyIteratorBase { - return _GeneratorBox(_base.generate()) + override func iterator() -> _AnyIteratorBase { + return _GeneratorBox(_base.iterator()) } override func _underestimateCount() -> Int { return Swift.underestimateCount(_base) @@ -176,7 +176,7 @@ internal class _CollectionBox : _AnyCollectionBox { typealias Element = S.Generator.Element - override func generate() -> _AnyIteratorBase { + override func iterator() -> _AnyIteratorBase { fatalError("") } override func _underestimateCount() -> Int { @@ -226,8 +226,8 @@ public struct AnySequence : SequenceType { /// Return a *generator* over the elements of this *sequence*. /// /// Complexity: O(1) - public func generate() -> AnyIterator { - return unsafeDowncast(_box.generate()) + public func iterator() -> AnyIterator { + return unsafeDowncast(_box.iterator()) } internal let _box: _AnySequenceBox @@ -757,8 +757,8 @@ public struct AnyForwardCollection : AnyCollectionType { /// Return a *generator* over the elements of this *collection*. /// /// Complexity: O(1) - public func generate() -> AnyIterator { - return unsafeDowncast(_box.generate()) + public func iterator() -> AnyIterator { + return unsafeDowncast(_box.iterator()) } /// The position of the first element in a non-empty collection. @@ -867,8 +867,8 @@ public struct AnyBidirectionalCollection : AnyCollectionType { /// Return a *generator* over the elements of this *collection*. /// /// Complexity: O(1) - public func generate() -> AnyIterator { - return unsafeDowncast(_box.generate()) + public func iterator() -> AnyIterator { + return unsafeDowncast(_box.iterator()) } /// The position of the first element in a non-empty collection. @@ -967,8 +967,8 @@ public struct AnyRandomAccessCollection : AnyCollectionType { /// Return a *generator* over the elements of this *collection*. /// /// Complexity: O(1) - public func generate() -> AnyIterator { - return unsafeDowncast(_box.generate()) + public func iterator() -> AnyIterator { + return unsafeDowncast(_box.iterator()) } /// The position of the first element in a non-empty collection. diff --git a/test/Interpreter/protocol_extensions.swift b/test/Interpreter/protocol_extensions.swift index 4170871acac68..64b239f6b5b50 100644 --- a/test/Interpreter/protocol_extensions.swift +++ b/test/Interpreter/protocol_extensions.swift @@ -122,7 +122,7 @@ extension RangeReplaceableCollectionType { elements: S ) -> Self { var result = Self() - var gen = elements.generate() + var gen = elements.iterator() if let first = gen.next() { result.appendContentsOf(first) while let next = gen.next() { diff --git a/test/NameBinding/Inputs/reference-dependencies-helper.swift b/test/NameBinding/Inputs/reference-dependencies-helper.swift index 223e070572252..c15a87d1e6070 100644 --- a/test/NameBinding/Inputs/reference-dependencies-helper.swift +++ b/test/NameBinding/Inputs/reference-dependencies-helper.swift @@ -24,7 +24,7 @@ struct OtherFileSecretTypeWrapper { struct OtherFileIntArray : SequenceType { var array: [Int] = [] - func generate() -> Array.Iterator { return array.generate() } + func iterator() -> Array.Iterator { return array.iterator() } } func getOtherFileIntArray() -> OtherFileIntArray { return OtherFileIntArray() } diff --git a/test/Parse/foreach.swift b/test/Parse/foreach.swift index abf3b11772c1d..e6d35f4dc90f4 100644 --- a/test/Parse/foreach.swift +++ b/test/Parse/foreach.swift @@ -5,7 +5,7 @@ struct IntRange : SequenceType, IteratorProtocol { func next() -> (Int, Int)? {} typealias Iterator = IntRange - func generate() -> IntRange { return self } + func iterator() -> IntRange { return self } } func for_each(r: Range, iir: IntRange) { diff --git a/test/Prototypes/MutableIndexableDict.swift b/test/Prototypes/MutableIndexableDict.swift index 06496d288cbeb..999e8960faffe 100644 --- a/test/Prototypes/MutableIndexableDict.swift +++ b/test/Prototypes/MutableIndexableDict.swift @@ -416,7 +416,7 @@ struct Dictionary : CollectionType, SequenceType { } // Satisfying SequenceType - func generate() -> IndexingGenerator<_Self> { + func iterator() -> IndexingGenerator<_Self> { return IndexingGenerator(self) } } diff --git a/test/SIL/Parser/witness_with_inherited_gp.sil b/test/SIL/Parser/witness_with_inherited_gp.sil index 3de76b6303a72..dbc4861671885 100644 --- a/test/SIL/Parser/witness_with_inherited_gp.sil +++ b/test/SIL/Parser/witness_with_inherited_gp.sil @@ -17,7 +17,7 @@ public struct mmEnumerateGenerator< public init(_ base: Base) public mutating func next() -> Element? public typealias Generator = mmEnumerateGenerator - public func generate() -> Generator + public func iterator() -> Generator } public struct mmEnumerateSequence< @@ -25,7 +25,7 @@ public struct mmEnumerateSequence< > : SequenceType { var base: Base public init(_ base: Base) - public func generate() -> mmEnumerateGenerator + public func iterator() -> mmEnumerateGenerator } // CHECK: sil_witness_table mmEnumerateSequence: _Sequence_Type module WitnessTableWithGP { @@ -43,7 +43,7 @@ public struct _mmArrayBuffer : CollectionType { public var startIndex: Int { get } public var endIndex: Int { get } public subscript(i: Int) -> T { get } - public func generate() -> IndexingGenerator<_mmArrayBuffer> + public func iterator() -> IndexingGenerator<_mmArrayBuffer> } sil_witness_table _mmArrayBuffer: _Sequence_Type module WitnessTableWithGP { diff --git a/test/SILGen/witness_same_type.swift b/test/SILGen/witness_same_type.swift index 4df98babad8bf..3bb2f131aa09a 100644 --- a/test/SILGen/witness_same_type.swift +++ b/test/SILGen/witness_same_type.swift @@ -18,9 +18,9 @@ struct Foo: Fooable { } // rdar://problem/19049566 -// CHECK-LABEL: sil [transparent] [thunk] @_TTWu0_Rxs12SequenceType_zWx8Iterator7Element_rGV17witness_same_type14LazySequenceOfxq__S_S2_FS_8generate +// CHECK-LABEL: sil [transparent] [thunk] @_TTWu0_Rxs12SequenceType_zWx8Iterator7Element_rGV17witness_same_type14LazySequenceOfxq__S_S2_FS_8iterator public struct LazySequenceOf : SequenceType { - public func generate() -> AnyIterator { + public func iterator() -> AnyIterator { var opt: AnyIterator? return opt! } diff --git a/test/SILPasses/prespecialize.swift b/test/SILPasses/prespecialize.swift index 44e7ea4d65385..95c785aa0bd24 100644 --- a/test/SILPasses/prespecialize.swift +++ b/test/SILPasses/prespecialize.swift @@ -6,8 +6,8 @@ // This test requires the standard library to be compiled with pre-specializations! // CHECK-LABEL: sil [noinline] @_TF13prespecialize4testFTRGSaSi_4sizeSi_T_ -// Look for generic specialization of Swift.Range.generate (Swift.Range)() -> Swift.RangeIterator -// CHECK: function_ref @_TTSg5SiSis16ForwardIndexTypes_SiSis18_SignedIntegerTypes_SiSis33_BuiltinIntegerLiteralConvertibles_Si___TFVs5Range8generate +// Look for generic specialization of Swift.Range.iterator (Swift.Range)() -> Swift.RangeIterator +// CHECK: function_ref @_TTSg5SiSis16ForwardIndexTypes_SiSis18_SignedIntegerTypes_SiSis33_BuiltinIntegerLiteralConvertibles_Si___TFVs5Range8iterator // Look for generic specialization of Swift.RangeIterator.next (inout Swift.RangeIterator)() -> Swift.Optional // CHECK: function_ref @_TTSg5SiSis16ForwardIndexTypes_SiSis18_SignedIntegerTypes_SiSis33_BuiltinIntegerLiteralConvertibles_Si___TFVs13RangeIterator4next // Look for generic specialization of Swift.Array.subscript.getter : (Swift.Int) -> A diff --git a/test/Serialization/Inputs/inherited-conformance-user.swift b/test/Serialization/Inputs/inherited-conformance-user.swift index 45eb26e5e22ad..56a38702796af 100644 --- a/test/Serialization/Inputs/inherited-conformance-user.swift +++ b/test/Serialization/Inputs/inherited-conformance-user.swift @@ -17,7 +17,7 @@ public struct OneToAThousand : CollectionType { return i.value } - public func generate() -> IndexingGenerator { + public func iterator() -> IndexingGenerator { return IndexingGenerator(self) } diff --git a/test/Serialization/multi-file.swift b/test/Serialization/multi-file.swift index 423cfd5b58e8c..27d0ad5c28cac 100644 --- a/test/Serialization/multi-file.swift +++ b/test/Serialization/multi-file.swift @@ -38,7 +38,7 @@ struct StructWithInheritedConformances: SequenceType { } } - func generate() -> EmptyIterator { + func iterator() -> EmptyIterator { return EmptyIterator() } } diff --git a/test/decl/protocol/protocols.swift b/test/decl/protocol/protocols.swift index d518257e61a5a..d9b1c298a2c1a 100644 --- a/test/decl/protocol/protocols.swift +++ b/test/decl/protocol/protocols.swift @@ -151,7 +151,7 @@ struct StreamTypeWithInferredAssociatedTypes : StreamWithAssoc { protocol SequenceViaStream { typealias SequenceStreamTypeType : IteratorProtocol // expected-note{{protocol requires nested type 'SequenceStreamTypeType'}} - func generate() -> SequenceStreamTypeType + func iterator() -> SequenceStreamTypeType } struct IntIterator : IteratorProtocol /*, SequenceType, ReplPrintable*/ { @@ -168,7 +168,7 @@ struct IntIterator : IteratorProtocol /*, SequenceType, ReplPrintable*/ { } typealias Generator = IntIterator - func generate() -> IntIterator { + func iterator() -> IntIterator { return self } } @@ -179,7 +179,7 @@ extension IntIterator : SequenceViaStream { struct NotSequence : SequenceViaStream { // expected-error{{type 'NotSequence' does not conform to protocol 'SequenceViaStream'}} typealias SequenceStreamTypeType = Int // expected-note{{possibly intended match 'SequenceStreamTypeType' (aka 'Int') does not conform to 'IteratorProtocol'}} - func generate() -> Int {} + func iterator() -> Int {} } protocol GetATuple { @@ -243,7 +243,7 @@ struct WrongIsEqual : IsEqualComparable { // expected-error{{type 'WrongIsEqual' //===----------------------------------------------------------------------===// func existentialSequence(e: SequenceType) { // expected-error{{has Self or associated type requirements}} - var x = e.generate() // expected-error{{type 'SequenceType' does not conform to protocol 'IteratorProtocol'}} + var x = e.iterator() // expected-error{{type 'SequenceType' does not conform to protocol 'IteratorProtocol'}} x.next() x.nonexistent() } @@ -256,7 +256,7 @@ protocol HasSequenceAndStream { func existentialSequenceAndStreamType(h: HasSequenceAndStream) { // expected-error{{has Self or associated type requirements}} // FIXME: Crummy diagnostics. var x = h.getR() // expected-error{{member 'getR' cannot be used on value of protocol type 'HasSequenceAndStream'; use a generic constraint instead}} - x.generate() + x.iterator() x.next() x.nonexistent() diff --git a/test/decl/protocol/req/associated_type_inference.swift b/test/decl/protocol/req/associated_type_inference.swift index ed377c8bd6057..6f39d68843b2a 100644 --- a/test/decl/protocol/req/associated_type_inference.swift +++ b/test/decl/protocol/req/associated_type_inference.swift @@ -233,7 +233,7 @@ struct Y7 : P7 { struct MyAnySequence : MySequenceType { typealias SubSequence = MyAnySequence - func generate() -> MyAnyIterator { + func iterator() -> MyAnyIterator { return MyAnyIterator() } } @@ -251,7 +251,7 @@ protocol MySequenceType { typealias SubSequence func foo() -> SubSequence - func generate() -> Iterator + func iterator() -> Iterator } extension MySequenceType { @@ -266,7 +266,7 @@ struct SomeStruct : MySequenceType { self.element = element } - func generate() -> MyAnyIterator { + func iterator() -> MyAnyIterator { return MyAnyIterator() } } diff --git a/test/decl/protocol/substituted_aliases.swift b/test/decl/protocol/substituted_aliases.swift index f20e85fb092d2..b699c2304ee46 100644 --- a/test/decl/protocol/substituted_aliases.swift +++ b/test/decl/protocol/substituted_aliases.swift @@ -1,8 +1,8 @@ // RUN: %target-parse-verify-swift struct Q : SequenceType { - func generate() -> T.Iterator { - return base.generate() + func iterator() -> T.Iterator { + return base.iterator() } func _adopt(newBuffer: Array.Iterator.Element>) { diff --git a/test/decl/var/usage.swift b/test/decl/var/usage.swift index 723b82499e172..903b8c5ba8b5e 100644 --- a/test/decl/var/usage.swift +++ b/test/decl/var/usage.swift @@ -183,7 +183,7 @@ func testFixitsInStatementsWithPatterns(a : Int?) { _ = b2 } - var g = [1,2,3].generate() + var g = [1,2,3].iterator() // FIXME: rdar://problem/23378003 // This will eventually be an error. while var x = g.next() { // expected-warning {{Use of 'var' binding here is deprecated and will be removed in a future version of Swift}} {{9-12=let}} diff --git a/test/stmt/foreach.swift b/test/stmt/foreach.swift index 38b80dd6bbaa2..e9a1af0c4fe6b 100644 --- a/test/stmt/foreach.swift +++ b/test/stmt/foreach.swift @@ -17,7 +17,7 @@ func bad_containers_2(bc: BadContainer2) { } struct BadContainer3 : SequenceType { // expected-error{{type 'BadContainer3' does not conform to protocol 'SequenceType'}} - func generate() { } // expected-note{{inferred type '()' (by matching requirement 'generate()') is invalid: does not conform to 'IteratorProtocol'}} + func iterator() { } // expected-note{{inferred type '()' (by matching requirement 'iterator()') is invalid: does not conform to 'IteratorProtocol'}} } func bad_containers_3(bc: BadContainer3) { @@ -28,7 +28,7 @@ struct BadIterator1 {} struct BadContainer4 : SequenceType { // expected-error{{type 'BadContainer4' does not conform to protocol 'SequenceType'}} typealias Iterator = BadIterator1 // expected-note{{possibly intended match 'Iterator' (aka 'BadIterator1') does not conform to 'IteratorProtocol'}} - func generate() -> BadIterator1 { } + func iterator() -> BadIterator1 { } } func bad_containers_4(bc: BadContainer4) { @@ -42,7 +42,7 @@ struct GoodRange : SequenceType, IteratorProtocol { func next() -> Int? {} typealias Iterator = GoodRange - func generate() -> GoodRange { return self } + func iterator() -> GoodRange { return self } } struct GoodTupleIterator: SequenceType, IteratorProtocol { @@ -50,7 +50,7 @@ struct GoodTupleIterator: SequenceType, IteratorProtocol { func next() -> (Int, Float)? {} typealias Iterator = GoodTupleIterator - func generate() -> GoodTupleIterator {} + func iterator() -> GoodTupleIterator {} } func patterns(gir: GoodRange, gtr: GoodTupleIterator) { @@ -99,7 +99,7 @@ struct Gen : IteratorProtocol { } struct Seq : SequenceType { - func generate() -> Gen { return Gen() } + func iterator() -> Gen { return Gen() } } func getIntSeq() -> Seq { return Seq() } diff --git a/test/type/nested_types.swift b/test/type/nested_types.swift index 73f2141b18d56..21e60296dfe6b 100644 --- a/test/type/nested_types.swift +++ b/test/type/nested_types.swift @@ -13,7 +13,7 @@ extension X { protocol MyIteratorProtocol {} protocol MySequence { typealias Iterator : MyIteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } struct IteratorWrapper { @@ -25,7 +25,7 @@ struct SequenceWrapper { var input : T typealias Iterator = IteratorWrapper - func generate() -> Iterator { - return Iterator(index: 0, elements: input.generate()) + func iterator() -> Iterator { + return Iterator(index: 0, elements: input.iterator()) } } diff --git a/validation-test/compiler_crashers_2_fixed/0003-rdar20564378.swift b/validation-test/compiler_crashers_2_fixed/0003-rdar20564378.swift index 4933b3f4c30df..e9d55936c7f24 100644 --- a/validation-test/compiler_crashers_2_fixed/0003-rdar20564378.swift +++ b/validation-test/compiler_crashers_2_fixed/0003-rdar20564378.swift @@ -3,7 +3,7 @@ public protocol Q_SequenceDefaultsType { typealias Element typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } extension Q_SequenceDefaultsType { @@ -20,7 +20,7 @@ extension Q_SequenceDefaultsType { var result = _ContiguousArrayBuffer( count: initialCapacity, minimumCapacity: 0) - var g = self.generate() + var g = self.iterator() while let x = g.next() { result += CollectionOfOne(x) } @@ -33,7 +33,7 @@ extension Q_SequenceDefaultsType { baseAddress: UnsafeMutablePointer ) { var p = baseAddress - var g = self.generate() + var g = self.iterator() while let element = g.next() { p.initialize(element) ++p @@ -54,7 +54,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { /// encapsulates its iteration state. typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator /// Return a value less than or equal to the number of elements in /// self, **nondestructively**. @@ -82,7 +82,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { public extension IteratorProtocol { typealias Iterator = Self - public final func generate() -> Iterator { + public final func iterator() -> Iterator { return self } } @@ -110,7 +110,7 @@ extension Q_CollectionDefaultsType { /* typealias Iterator = Q_IndexingIterator - public final func generate() -> Q_IndexingIterator { + public final func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } */ @@ -146,7 +146,7 @@ struct Boo : Q_CollectionType { let startIndex: Int = 0 let endIndex: Int = 10 - func generate() -> Q_IndexingIterator { + func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } diff --git a/validation-test/compiler_crashers_2_fixed/0004-rdar20564605.swift b/validation-test/compiler_crashers_2_fixed/0004-rdar20564605.swift index 58fc9955d81fe..5760d1261cff7 100644 --- a/validation-test/compiler_crashers_2_fixed/0004-rdar20564605.swift +++ b/validation-test/compiler_crashers_2_fixed/0004-rdar20564605.swift @@ -3,7 +3,7 @@ public protocol Q_SequenceDefaultsType { typealias Element typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } extension Q_SequenceDefaultsType { @@ -20,7 +20,7 @@ extension Q_SequenceDefaultsType { var result = _ContiguousArrayBuffer( count: initialCapacity, minimumCapacity: 0) - var g = self.generate() + var g = self.iterator() while let x = g.next() { result += CollectionOfOne(x) } @@ -33,7 +33,7 @@ extension Q_SequenceDefaultsType { baseAddress: UnsafeMutablePointer ) { var p = baseAddress - var g = self.generate() + var g = self.iterator() while let element = g.next() { p.initialize(element) ++p @@ -54,7 +54,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { /// encapsulates its iteration state. typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator /// Return a value less than or equal to the number of elements in /// self, **nondestructively**. @@ -82,7 +82,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { public extension IteratorProtocol { typealias Iterator = Self - public final func generate() -> Iterator { + public final func iterator() -> Iterator { return self } } @@ -105,7 +105,7 @@ public protocol Q_Indexable { extension Q_Indexable { typealias Iterator = Q_IndexingIterator - public final func generate() -> Q_IndexingIterator { + public final func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } } @@ -155,7 +155,7 @@ struct Boo : Q_CollectionType { let startIndex: Int = 0 let endIndex: Int = 10 - func generate() -> Q_IndexingIterator { + func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } diff --git a/validation-test/compiler_crashers_2_fixed/0006-rdar20588474.swift b/validation-test/compiler_crashers_2_fixed/0006-rdar20588474.swift index 49ddfbc83ef7e..2e5942697005e 100644 --- a/validation-test/compiler_crashers_2_fixed/0006-rdar20588474.swift +++ b/validation-test/compiler_crashers_2_fixed/0006-rdar20588474.swift @@ -3,7 +3,7 @@ public protocol Q_SequenceDefaultsType { typealias Element typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } extension Q_SequenceDefaultsType { @@ -20,7 +20,7 @@ extension Q_SequenceDefaultsType { var result = _ContiguousArrayBuffer( count: initialCapacity, minimumCapacity: 0) - var g = self.generate() + var g = self.iterator() while let x = g.next() { result += CollectionOfOne(x) } @@ -33,7 +33,7 @@ extension Q_SequenceDefaultsType { baseAddress: UnsafeMutablePointer ) { var p = baseAddress - var g = self.generate() + var g = self.iterator() while let element = g.next() { p.initialize(element) ++p @@ -54,7 +54,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { /// encapsulates its iteration state. typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator /// Return a value less than or equal to the number of elements in /// self, **nondestructively**. @@ -82,7 +82,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { public extension IteratorProtocol { // typealias Iterator = Self - public final func generate() -> Self { + public final func iterator() -> Self { return self } } @@ -112,7 +112,7 @@ extension Q_CollectionDefaultsType { return body(self) } - public final func generate() -> Q_IndexingIterator { + public final func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } } @@ -151,7 +151,7 @@ struct Boo : Q_CollectionType { return "Boo" } - func generate() -> Q_IndexingIterator { + func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } } diff --git a/validation-test/compiler_crashers_2_fixed/0010-rdar20638881.swift b/validation-test/compiler_crashers_2_fixed/0010-rdar20638881.swift index 782259705a294..998d414116ce6 100644 --- a/validation-test/compiler_crashers_2_fixed/0010-rdar20638881.swift +++ b/validation-test/compiler_crashers_2_fixed/0010-rdar20638881.swift @@ -2,7 +2,7 @@ public protocol Q_SequenceDefaultsType { typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } extension Q_SequenceDefaultsType { @@ -21,7 +21,7 @@ extension Q_SequenceDefaultsType { var result = _ContiguousArrayBuffer( count: initialCapacity, minimumCapacity: 0) - var g = self.generate() + var g = self.iterator() while let x? = g.next() { result += CollectionOfOne(x) } @@ -34,7 +34,7 @@ extension Q_SequenceDefaultsType { baseAddress: UnsafeMutablePointer ) { var p = baseAddress - var g = self.generate() + var g = self.iterator() while let element? = g.next() { p.initialize(element) ++p @@ -55,7 +55,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { /// encapsulates its iteration state. typealias Iterator : IteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator /// Return a value less than or equal to the number of elements in /// self, **nondestructively**. @@ -81,7 +81,7 @@ public protocol Q_SequenceType : Q_SequenceDefaultsType { } public extension IteratorProtocol { - public final func generate() -> Self { + public final func iterator() -> Self { return self } } @@ -97,7 +97,7 @@ public protocol Q_IndexableType { } extension Q_IndexableType { - public final func generate() -> Q_IndexingIterator { + public final func iterator() -> Q_IndexingIterator { return Q_IndexingIterator(pos: self.startIndex, elements: self) } } diff --git a/validation-test/compiler_crashers_2_fixed/0013-rdar19519590.swift b/validation-test/compiler_crashers_2_fixed/0013-rdar19519590.swift index 98da91cd6fe81..2b0c5c6691832 100644 --- a/validation-test/compiler_crashers_2_fixed/0013-rdar19519590.swift +++ b/validation-test/compiler_crashers_2_fixed/0013-rdar19519590.swift @@ -62,7 +62,7 @@ struct PiecewiseTransformedSequenceOf< self.transformers = transformers } - func generate() -> Iterator { - return PiecewiseTransformedIteratorOf(sourceIterator: inputs.generate(), transformerIterator: transformers.generate()) + func iterator() -> Iterator { + return PiecewiseTransformedIteratorOf(sourceIterator: inputs.iterator(), transformerIterator: transformers.iterator()) } } diff --git a/validation-test/compiler_crashers_2_fixed/0014-rdar20508671.swift b/validation-test/compiler_crashers_2_fixed/0014-rdar20508671.swift index f606e1cb1a554..d31b7b5c7f0f3 100644 --- a/validation-test/compiler_crashers_2_fixed/0014-rdar20508671.swift +++ b/validation-test/compiler_crashers_2_fixed/0014-rdar20508671.swift @@ -7,12 +7,12 @@ protocol MyIteratorProtocol { protocol MySequenceType { typealias Iterator : MyIteratorProtocol - func generate() -> Iterator + func iterator() -> Iterator } protocol MyCollectionDefaultsType : MySequenceType {} extension MyCollectionDefaultsType { - final func generate() -> DefaultIterator { + final func iterator() -> DefaultIterator { return DefaultIterator() } } @@ -31,5 +31,5 @@ struct FooIteratorWrapper { } func f(c: C) { - FooIteratorWrapper(c.generate()) + FooIteratorWrapper(c.iterator()) } diff --git a/validation-test/compiler_crashers_2_fixed/0018-rdar21524144.swift b/validation-test/compiler_crashers_2_fixed/0018-rdar21524144.swift index a4835d688a075..94f05266e25ee 100644 --- a/validation-test/compiler_crashers_2_fixed/0018-rdar21524144.swift +++ b/validation-test/compiler_crashers_2_fixed/0018-rdar21524144.swift @@ -13,7 +13,7 @@ protocol CollectionType : Indexable, SequenceType {} public struct IndexingGenerator : IteratorProtocol, SequenceType { - public func generate() -> IndexingGenerator { + public func iterator() -> IndexingGenerator { return self } @@ -23,7 +23,7 @@ public struct IndexingGenerator } extension SequenceType where Self : CollectionType { - func generate() -> IndexingGenerator { + func iterator() -> IndexingGenerator { return IndexingGenerator(self) } } diff --git a/validation-test/compiler_crashers_2_fixed/0019-rdar21511651.swift b/validation-test/compiler_crashers_2_fixed/0019-rdar21511651.swift index 0f31545a425ce..c1415c4ba4856 100644 --- a/validation-test/compiler_crashers_2_fixed/0019-rdar21511651.swift +++ b/validation-test/compiler_crashers_2_fixed/0019-rdar21511651.swift @@ -9,8 +9,8 @@ internal protocol _SequenceWrapperType { extension SequenceType where Self : _SequenceWrapperType, Self.Iterator == Self.Base.Iterator { - public func generate() -> Base.Iterator { - return self._base.generate() + public func iterator() -> Base.Iterator { + return self._base.iterator() } public func underestimateCount() -> Int { @@ -134,7 +134,7 @@ public func _prext_lazy(s: S) -> _prext_LazySequence { public extension SequenceType where Self.Iterator == Self, Self : IteratorProtocol { - public func generate() -> Self { + public func iterator() -> Self { return self } } @@ -230,9 +230,9 @@ public struct _prext_MapSequence typealias Elements = _prext_MapSequence - public func generate() -> _prext_MapIterator { + public func iterator() -> _prext_MapIterator { return _prext_MapIterator( - _base: _base.generate(), _transform: _transform) + _base: _base.iterator(), _transform: _transform) } var _base: Base @@ -259,8 +259,8 @@ public struct _prext_MapCollection return _transform(_base[position]) } - public func generate() -> _prext_MapIterator { - return _prext_MapIterator(_base: _base.generate(), _transform: _transform) + public func iterator() -> _prext_MapIterator { + return _prext_MapIterator(_base: _base.iterator(), _transform: _transform) } public func underestimateCount() -> Int { diff --git a/validation-test/compiler_crashers_2_fixed/0020-rdar21598514.swift b/validation-test/compiler_crashers_2_fixed/0020-rdar21598514.swift index 708dad6b46298..149cc12cbd5c5 100644 --- a/validation-test/compiler_crashers_2_fixed/0020-rdar21598514.swift +++ b/validation-test/compiler_crashers_2_fixed/0020-rdar21598514.swift @@ -98,9 +98,9 @@ extension LoggingSequenceType { self.base = base } - public func generate() -> LoggingIterator { + public func iterator() -> LoggingIterator { ++SequenceLog.generate[selfType] - return LoggingIterator(base.generate()) + return LoggingIterator(base.iterator()) } public func underestimateCount() -> Int { diff --git a/validation-test/compiler_crashers_2_fixed/0022-rdar21625478.swift b/validation-test/compiler_crashers_2_fixed/0022-rdar21625478.swift index 4add208c6b80f..f68439259e7a9 100644 --- a/validation-test/compiler_crashers_2_fixed/0022-rdar21625478.swift +++ b/validation-test/compiler_crashers_2_fixed/0022-rdar21625478.swift @@ -111,9 +111,9 @@ public protocol LoggingSequenceType : SequenceType, LoggingType { extension LoggingSequenceType where Log == SequenceLog, Iterator == LoggingIterator { - public func generate() -> LoggingIterator { + public func iterator() -> LoggingIterator { ++Log.generate[selfType] - return LoggingIterator(base.generate()) + return LoggingIterator(base.iterator()) } public func underestimateCount() -> Int { @@ -250,8 +250,8 @@ public struct LoggingCollection : LoggingCollectionType { public typealias Base = Base_ public typealias SubSequence = Base.SubSequence - public func generate() -> Iterator { - return Iterator(base.generate()) + public func iterator() -> Iterator { + return Iterator(base.iterator()) } public init(_ base: Base_) { self.base = base diff --git a/validation-test/compiler_crashers_2_fixed/0027-rdar21514140.swift b/validation-test/compiler_crashers_2_fixed/0027-rdar21514140.swift index 8bb38f998c2ab..ee483d2b910ae 100644 --- a/validation-test/compiler_crashers_2_fixed/0027-rdar21514140.swift +++ b/validation-test/compiler_crashers_2_fixed/0027-rdar21514140.swift @@ -11,8 +11,8 @@ internal protocol _SequenceWrapperType { extension SequenceType where Self : _SequenceWrapperType, Self.Iterator == Self.Base.Iterator { - public func generate() -> Base.Iterator { - return self._base.generate() + public func iterator() -> Base.Iterator { + return self._base.iterator() } public func underestimateCount() -> Int { @@ -136,7 +136,7 @@ public func _prext_lazy(s: S) -> _prext_LazySequence { public extension SequenceType where Self.Iterator == Self, Self : IteratorProtocol { - public func generate() -> Self { + public func iterator() -> Self { return self } } @@ -233,9 +233,9 @@ public struct _prext_MapSequence typealias Elements = _prext_MapSequence - public func generate() -> _prext_MapIterator { + public func iterator() -> _prext_MapIterator { return _prext_MapIterator( - _base: _base.generate(), _transform: _transform) + _base: _base.iterator(), _transform: _transform) } var _base: Base @@ -262,8 +262,8 @@ public struct _prext_MapCollection return _transform(_base[position]) } - public func generate() -> _prext_MapIterator { - return _prext_MapIterator(_base: _base.generate(), _transform: _transform) + public func iterator() -> _prext_MapIterator { + return _prext_MapIterator(_base: _base.iterator(), _transform: _transform) } public func underestimateCount() -> Int { diff --git a/validation-test/stdlib/Algorithm.swift b/validation-test/stdlib/Algorithm.swift index 275685f6491e6..af0928663368b 100644 --- a/validation-test/stdlib/Algorithm.swift +++ b/validation-test/stdlib/Algorithm.swift @@ -56,8 +56,8 @@ struct A : MutableSliceable { return impl.count } - func generate() -> Array.Iterator { - return impl.generate() + func iterator() -> Array.Iterator { + return impl.iterator() } subscript(i: Int) -> T { diff --git a/validation-test/stdlib/ArrayNew.swift.gyb b/validation-test/stdlib/ArrayNew.swift.gyb index ce55222432ac6..af1d46611babb 100644 --- a/validation-test/stdlib/ArrayNew.swift.gyb +++ b/validation-test/stdlib/ArrayNew.swift.gyb @@ -122,8 +122,8 @@ struct SequenceWithCustomUnderestimateCount : SequenceType { self._data = MinimalSequence(elements: data.map(OpaqueValue.init)) } - func generate() -> MinimalSequence>.Iterator { - return _data.generate() + func iterator() -> MinimalSequence>.Iterator { + return _data.iterator() } func underestimateCount() -> Int { @@ -456,7 +456,7 @@ ArrayTestSuite.test("${array_type}/_withUnsafeMutableBufferPointerIfSupported/Re ArrayTestSuite.test( "${array_type}/mutationDoesNotAffectIterator/subscript/store") { var arr: ${array_type} = [ 1010, 1020, 1030 ] - var g = arr.generate() + var g = arr.iterator() arr[0] = 1011 expectEqual([ 1010, 1020, 1030 ], Array(IteratorSequence(g))) } @@ -464,7 +464,7 @@ ArrayTestSuite.test( ArrayTestSuite.test( "${array_type}/mutationDoesNotAffectIterator/subscript/append") { var arr: ${array_type} = [ 1010, 1020, 1030 ] - var g = arr.generate() + var g = arr.iterator() arr.append(1040) expectEqual([ 1010, 1020, 1030 ], Array(IteratorSequence(g))) } @@ -472,7 +472,7 @@ ArrayTestSuite.test( ArrayTestSuite.test( "${array_type}/mutationDoesNotAffectIterator/subscript/replaceRange") { var arr: ${array_type} = [ 1010, 1020, 1030 ] - var g = arr.generate() + var g = arr.iterator() arr.replaceRange(1..<3, with: [ 1040, 1050, 1060 ]) expectEqual([ 1010, 1020, 1030 ], Array(IteratorSequence(g))) } @@ -1593,7 +1593,7 @@ final class EvilCollection : CollectionType { return TestValueTy(i) } - func generate() -> IndexingGenerator { + func iterator() -> IndexingGenerator { return IndexingGenerator(self) } } diff --git a/validation-test/stdlib/CollectionType.swift.gyb b/validation-test/stdlib/CollectionType.swift.gyb index 4bd3739517d79..158197e1fe756 100644 --- a/validation-test/stdlib/CollectionType.swift.gyb +++ b/validation-test/stdlib/CollectionType.swift.gyb @@ -17,7 +17,7 @@ struct CollectionWithDefaultUnderestimateCount : CollectionType { self._count = count } - func generate() -> MinimalIterator> { + func iterator() -> MinimalIterator> { expectUnreachable() return MinimalIterator([]) } @@ -56,8 +56,8 @@ struct MinimalForwardCollectionWith${Implementation}Filter elements: data, underestimatedCount: underestimatedCount) } - func generate() -> MinimalIterator { - return _data.generate() + func iterator() -> MinimalIterator { + return _data.iterator() } var startIndex: MinimalForwardIndex { @@ -188,8 +188,8 @@ struct MinimalForwardCollectionWith${Implementation}Map elements: data, underestimatedCount: underestimatedCount) } - func generate() -> MinimalIterator { - return _data.generate() + func iterator() -> MinimalIterator { + return _data.iterator() } var startIndex: MinimalForwardIndex { @@ -339,7 +339,7 @@ struct CollectionWithCustomUnderestimateCount : CollectionType { self._underestimatedCount = underestimatedCount } - func generate() -> MinimalIterator> { + func iterator() -> MinimalIterator> { expectUnreachable() return MinimalIterator([]) } @@ -379,7 +379,7 @@ CollectionTypeTests.test("underestimateCount/CollectionType/CustomImplementation } //===----------------------------------------------------------------------===// -// CollectionType.generate(), CollectionType.Iterator +// CollectionType.iterator(), CollectionType.Iterator //===----------------------------------------------------------------------===// struct MinimalForwardCollectionWithDefaultIterator : CollectionType { @@ -404,16 +404,16 @@ struct MinimalForwardCollectionWithDefaultIterator : CollectionType { } func callGenericGenerate(sequence: S) -> S.Iterator { - return sequence.generate() + return sequence.iterator() } -CollectionTypeTests.test("CollectionType.generate()/DefaultImplementation") { +CollectionTypeTests.test("CollectionType.iterator()/DefaultImplementation") { for count in [ 0, 5 ] { let collection = MinimalForwardCollectionWithDefaultIterator(count: count) if true { // Check the return type of the function when called statically. - var generator = collection.generate() + var generator = collection.iterator() expectType( IndexingGenerator.self, &generator) @@ -441,7 +441,7 @@ struct MinimalForwardCollectionWithCustomIterator : CollectionType { static var timesGenerateWasCalled: Int = 0 - func generate() -> MinimalIterator> { + func iterator() -> MinimalIterator> { ++MinimalForwardCollectionWithCustomIterator.timesGenerateWasCalled return MinimalIterator>( Array(1..<_count+1).map(OpaqueValue.init) as [OpaqueValue] @@ -464,14 +464,14 @@ struct MinimalForwardCollectionWithCustomIterator : CollectionType { var _count: Int } -CollectionTypeTests.test("CollectionType.generate()/CustomImplementation") { +CollectionTypeTests.test("CollectionType.iterator()/CustomImplementation") { for count in [ 0, 5 ] { let collection = MinimalForwardCollectionWithCustomIterator(count: count) if true { // Check the return type of the function when called statically. MinimalForwardCollectionWithCustomIterator.timesGenerateWasCalled = 0 - var generator = collection.generate() + var generator = collection.iterator() expectType( MinimalIterator>.self, &generator) diff --git a/validation-test/stdlib/Dictionary.swift b/validation-test/stdlib/Dictionary.swift index 19b452c553083..e65086eecffe6 100644 --- a/validation-test/stdlib/Dictionary.swift +++ b/validation-test/stdlib/Dictionary.swift @@ -882,7 +882,7 @@ DictionaryTestSuite.test("COW.Fast.GenerateDoesNotReallocate") { var d = getCOWFastDictionary() var identity1 = unsafeBitCast(d, Int.self) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { pairs += [(key, value)] @@ -895,7 +895,7 @@ DictionaryTestSuite.test("COW.Slow.GenerateDoesNotReallocate") { var d = getCOWSlowDictionary() var identity1 = unsafeBitCast(d, Int.self) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { // FIXME: This doesn't work ( Can't += @@ -2158,7 +2158,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Verbatim.Generate") { var identity1 = unsafeBitCast(d, Int.self) assert(isCocoaDictionary(d)) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = ((key as! TestObjCKeyTy).value, (value as! TestObjCValueTy).value) @@ -2178,7 +2178,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Nonverbatim.Generate") { var identity1 = unsafeBitCast(d, Int.self) assert(isNativeDictionary(d)) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = (key.value, value.value) @@ -2198,7 +2198,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Verbatim.Generate_Empty") { var identity1 = unsafeBitCast(d, Int.self) assert(isCocoaDictionary(d)) - var gen = d.generate() + var gen = d.iterator() // Can not write code below because of // Optional tuples are broken as optionals regarding == comparison // assert(gen.next() == .None) @@ -2216,7 +2216,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Nonverbatim.Generate_Empty") { var identity1 = unsafeBitCast(d, Int.self) assert(isNativeDictionary(d)) - var gen = d.generate() + var gen = d.iterator() // Can not write code below because of // Optional tuples are broken as optionals regarding == comparison // assert(gen.next() == .None) @@ -2235,7 +2235,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Verbatim.Generate_Huge") { var identity1 = unsafeBitCast(d, Int.self) assert(isCocoaDictionary(d)) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = ((key as! TestObjCKeyTy).value, (value as! TestObjCValueTy).value) @@ -2259,7 +2259,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Nonverbatim.Generate_Huge") { var identity1 = unsafeBitCast(d, Int.self) assert(isNativeDictionary(d)) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = (key.value, value.value) @@ -2288,7 +2288,7 @@ autoreleasepoolIfUnoptimizedReturnAutoreleased { var identity1 = unsafeBitCast(d, Int.self) assert(isCocoaDictionary(d)) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = ((key as! TestObjCKeyTy).value, (value as! TestObjCValueTy).value) @@ -2314,7 +2314,7 @@ autoreleasepoolIfUnoptimizedReturnAutoreleased { var identity1 = unsafeBitCast(d, Int.self) assert(isNativeDictionary(d)) - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = (key.value, value.value) @@ -2481,7 +2481,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Verbatim.ArrayOfDictionaries") { var a = nsa as [AnyObject] as! [Dictionary] for i in 0..<3 { var d = a[i] - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = ((key as! TestObjCKeyTy).value, (value as! TestObjCValueTy).value) @@ -2502,7 +2502,7 @@ DictionaryTestSuite.test("BridgedFromObjC.Nonverbatim.ArrayOfDictionaries") { var a = nsa as [AnyObject] as! [Dictionary] for i in 0..<3 { var d = a[i] - var gen = d.generate() + var gen = d.iterator() var pairs = Array<(Int, Int)>() while let (key, value) = gen.next() { let kv = (key.value, value.value) @@ -3680,7 +3680,7 @@ ObjCThunks.test("Dictionary/Return") { DictionaryTestSuite.test("mutationDoesNotAffectIterator/subscript/store") { var dict = getDerivedAPIsDictionary() - var g = dict.generate() + var g = dict.iterator() dict[10] = 1011 expectEqualsUnordered( @@ -3690,7 +3690,7 @@ DictionaryTestSuite.test("mutationDoesNotAffectIterator/subscript/store") { DictionaryTestSuite.test("mutationDoesNotAffectIterator/removeValueForKey,1") { var dict = getDerivedAPIsDictionary() - var g = dict.generate() + var g = dict.iterator() expectOptionalEqual(1010, dict.removeValueForKey(10)) expectEqualsUnordered( @@ -3700,7 +3700,7 @@ DictionaryTestSuite.test("mutationDoesNotAffectIterator/removeValueForKey,1") { DictionaryTestSuite.test("mutationDoesNotAffectIterator/removeValueForKey,all") { var dict = getDerivedAPIsDictionary() - var g = dict.generate() + var g = dict.iterator() expectOptionalEqual(1010, dict.removeValueForKey(10)) expectOptionalEqual(1020, dict.removeValueForKey(20)) expectOptionalEqual(1030, dict.removeValueForKey(30)) @@ -3713,7 +3713,7 @@ DictionaryTestSuite.test("mutationDoesNotAffectIterator/removeValueForKey,all") DictionaryTestSuite.test( "mutationDoesNotAffectIterator/removeAll,keepCapacity=false") { var dict = getDerivedAPIsDictionary() - var g = dict.generate() + var g = dict.iterator() dict.removeAll(keepCapacity: false) expectEqualsUnordered( @@ -3724,7 +3724,7 @@ DictionaryTestSuite.test( DictionaryTestSuite.test( "mutationDoesNotAffectIterator/removeAll,keepCapacity=true") { var dict = getDerivedAPIsDictionary() - var g = dict.generate() + var g = dict.iterator() dict.removeAll(keepCapacity: true) expectEqualsUnordered( diff --git a/validation-test/stdlib/SequenceType.swift.gyb b/validation-test/stdlib/SequenceType.swift.gyb index 417f5cb3e0e22..1be7e8f7863c7 100644 --- a/validation-test/stdlib/SequenceType.swift.gyb +++ b/validation-test/stdlib/SequenceType.swift.gyb @@ -161,7 +161,7 @@ SequenceTypeTests.test("IteratorSequence/IteratorProtocol/empty") { } if true { let data: [OpaqueValue] = [] - let base = data.generate() + let base = data.iterator() var g = IteratorSequence(base) expectType( IteratorSequence>>>.self, @@ -182,7 +182,7 @@ SequenceTypeTests.test("IteratorSequence/IteratorProtocol") { } if true { let data: [OpaqueValue] = [] - let base = data.generate() + let base = data.iterator() var g = IteratorSequence(base) expectType( IteratorSequence>>>.self, @@ -203,7 +203,7 @@ SequenceTypeTests.test("IteratorSequence/SequenceType/empty") { } if true { let data = [ 10, 20, 30 ].map(OpaqueValue.init) - let base = data.generate() + let base = data.iterator() var g = IteratorSequence(base) expectType( IteratorSequence>>>.self, @@ -224,7 +224,7 @@ SequenceTypeTests.test("IteratorSequence/SequenceType") { } if true { let data = [ 10, 20, 30 ].map(OpaqueValue.init) - let base = data.generate() + let base = data.iterator() var g = IteratorSequence(base) expectType( IteratorSequence>>>.self, @@ -754,8 +754,8 @@ struct MinimalSequenceWith${Implementation}Map : SequenceType { elements: data, underestimatedCount: underestimatedCount) } - func generate() -> MinimalIterator { - return _data.generate() + func iterator() -> MinimalIterator { + return _data.iterator() } var _data: MinimalSequence @@ -1057,11 +1057,11 @@ SequenceTypeTests.test("zip") { struct SequenceWithDefaultUnderestimateCount : SequenceType { init() {} - func generate() -> MinimalSequence>.Iterator { + func iterator() -> MinimalSequence>.Iterator { expectUnreachable() return MinimalSequence( elements: [ 1, 2, 3 ].map(OpaqueValue.init) - ).generate() + ).iterator() } } @@ -1075,11 +1075,11 @@ struct SequenceWithCustomUnderestimateCount : SequenceType { self._underestimatedCount = underestimatedCount } - func generate() -> MinimalSequence>.Iterator { + func iterator() -> MinimalSequence>.Iterator { expectUnreachable() return MinimalSequence( elements: [ 0xffff, 0xffff, 0xffff ].map(OpaqueValue.init) - ).generate() + ).iterator() } func underestimateCount() -> Int { diff --git a/validation-test/stdlib/Set.swift b/validation-test/stdlib/Set.swift index a08fed22f67f5..6e6f557b5ac2a 100644 --- a/validation-test/stdlib/Set.swift +++ b/validation-test/stdlib/Set.swift @@ -995,7 +995,7 @@ SetTestSuite.test("COW.Fast.GenerateDoesNotReallocate") { var s = getCOWFastSet() var identity1 = unsafeBitCast(s, Int.self) - var gen = s.generate() + var gen = s.iterator() var items: [Int] = [] while let value = gen.next() { items += [value] @@ -1008,7 +1008,7 @@ SetTestSuite.test("COW.Slow.GenerateDoesNotReallocate") { var s = getCOWSlowSet() var identity1 = unsafeBitCast(s, Int.self) - var gen = s.generate() + var gen = s.iterator() var items: [Int] = [] while let value = gen.next() { items.append(value.value) @@ -1893,7 +1893,7 @@ SetTestSuite.test("BridgedFromObjC.Verbatim.Generate") { var identity1 = unsafeBitCast(s, Int.self) expectTrue(isCocoaSet(s)) - var gen = s.generate() + var gen = s.iterator() var members: [Int] = [] while let member = gen.next() { members.append((member as! TestObjCKeyTy).value) @@ -1912,7 +1912,7 @@ SetTestSuite.test("BridgedFromObjC.Nonverbatim.Generate") { var identity1 = unsafeBitCast(s, Int.self) expectTrue(isNativeSet(s)) - var gen = s.generate() + var gen = s.iterator() var members: [Int] = [] while let member = gen.next() { members.append(member.value) @@ -1931,7 +1931,7 @@ SetTestSuite.test("BridgedFromObjC.Verbatim.Generate_Empty") { var identity1 = unsafeBitCast(s, Int.self) expectTrue(isCocoaSet(s)) - var gen = s.generate() + var gen = s.iterator() expectEmpty(gen.next()) // The following is not required by the IteratorProtocol protocol, but // it is a nice QoI. @@ -1946,7 +1946,7 @@ SetTestSuite.test("BridgedFromObjC.Nonverbatim.Generate_Empty") { var identity1 = unsafeBitCast(s, Int.self) expectTrue(isNativeSet(s)) - var gen = s.generate() + var gen = s.iterator() expectEmpty(gen.next()) // The following is not required by the IteratorProtocol protocol, but // it is a nice QoI. @@ -1961,7 +1961,7 @@ SetTestSuite.test("BridgedFromObjC.Verbatim.Generate_Huge") { var identity1 = unsafeBitCast(s, Int.self) expectTrue(isCocoaSet(s)) - var gen = s.generate() + var gen = s.iterator() var members = [Int]() while let member = gen.next() { members.append((member as! TestObjCKeyTy).value) @@ -1980,7 +1980,7 @@ SetTestSuite.test("BridgedFromObjC.Nonverbatim.Generate_Huge") { var identity1 = unsafeBitCast(s, Int.self) expectTrue(isNativeSet(s)) - var gen = s.generate() + var gen = s.iterator() var members = [Int]() while let member = gen.next() as AnyObject? { members.append((member as! TestBridgedKeyTy).value) @@ -2081,7 +2081,7 @@ SetTestSuite.test("BridgedFromObjC.Verbatim.ArrayOfSets") { var a = nsa as [AnyObject] as! [Set] for i in 0..<3 { var s = a[i] - var gen = s.generate() + var gen = s.iterator() var items: [Int] = [] while let value = gen.next() { let v = (value as! TestObjCKeyTy).value @@ -2102,7 +2102,7 @@ SetTestSuite.test("BridgedFromObjC.Nonverbatim.ArrayOfSets") { var a = nsa as [AnyObject] as! [Set] for i in 0..<3 { var d = a[i] - var gen = d.generate() + var gen = d.iterator() var items: [Int] = [] while let value = gen.next() { items.append(value.value) @@ -3669,7 +3669,7 @@ SetTestSuite.test("Operator.Precedence") { SetTestSuite.test("mutationDoesNotAffectIterator/remove,1") { var set = Set([ 1010, 1020, 1030 ]) - var g = set.generate() + var g = set.iterator() expectOptionalEqual(1010, set.remove(1010)) expectEqualsUnordered([ 1010, 1020, 1030 ], Array(IteratorSequence(g))) @@ -3677,7 +3677,7 @@ SetTestSuite.test("mutationDoesNotAffectIterator/remove,1") { SetTestSuite.test("mutationDoesNotAffectIterator/remove,all") { var set = Set([ 1010, 1020, 1030 ]) - var g = set.generate() + var g = set.iterator() expectOptionalEqual(1010, set.remove(1010)) expectOptionalEqual(1020, set.remove(1020)) expectOptionalEqual(1030, set.remove(1030)) @@ -3687,7 +3687,7 @@ SetTestSuite.test("mutationDoesNotAffectIterator/remove,all") { SetTestSuite.test("mutationDoesNotAffectIterator/removeAll,keepCapacity=false") { var set = Set([ 1010, 1020, 1030 ]) - var g = set.generate() + var g = set.iterator() set.removeAll(keepCapacity: false) expectEqualsUnordered([ 1010, 1020, 1030 ], Array(IteratorSequence(g))) @@ -3695,7 +3695,7 @@ SetTestSuite.test("mutationDoesNotAffectIterator/removeAll,keepCapacity=false") SetTestSuite.test("mutationDoesNotAffectIterator/removeAll,keepCapacity=true") { var set = Set([ 1010, 1020, 1030 ]) - var g = set.generate() + var g = set.iterator() set.removeAll(keepCapacity: true) expectEqualsUnordered([ 1010, 1020, 1030 ], Array(IteratorSequence(g))) diff --git a/validation-test/stdlib/Unicode.swift b/validation-test/stdlib/Unicode.swift index cc2bb7d729b88..e7e899cbb631b 100644 --- a/validation-test/stdlib/Unicode.swift +++ b/validation-test/stdlib/Unicode.swift @@ -1898,7 +1898,7 @@ UTF16Decoder.test("measure") { if true { var u8: [UTF8.CodeUnit] = [ 0, 1, 2, 3, 4, 5 ] let (count, isASCII) = UTF16.measure( - UTF8.self, input: u8.generate(), repairIllFormedSequences: false)! + UTF8.self, input: u8.iterator(), repairIllFormedSequences: false)! expectEqual(6, count) expectTrue(isASCII) } @@ -1907,7 +1907,7 @@ UTF16Decoder.test("measure") { // "€" == U+20AC. var u8: [UTF8.CodeUnit] = [ 0xF0, 0xA4, 0xAD, 0xA2 ] let (count, isASCII) = UTF16.measure( - UTF8.self, input: u8.generate(), repairIllFormedSequences: false)! + UTF8.self, input: u8.iterator(), repairIllFormedSequences: false)! expectEqual(2, count) expectFalse(isASCII) } @@ -1915,7 +1915,7 @@ UTF16Decoder.test("measure") { if true { let u16: [UTF16.CodeUnit] = [ 6, 7, 8, 9, 10, 11 ] let (count, isASCII) = UTF16.measure( - UTF16.self, input: u16.generate(), repairIllFormedSequences: false)! + UTF16.self, input: u16.iterator(), repairIllFormedSequences: false)! expectEqual(6, count) expectTrue(isASCII) } @@ -2085,7 +2085,7 @@ UnicodeAPIs.test("transcode/MutableArray") { var input: [UInt16] = [ 0x0041, 0x0042 ] var transcoded = [UInt16]() let output: (UInt16) -> Void = { transcoded.append($0) } - transcode(UTF16.self, UTF16.self, input.generate(), output, stopOnError: true) + transcode(UTF16.self, UTF16.self, input.iterator(), output, stopOnError: true) expectEqual(input, transcoded) } @@ -2093,7 +2093,7 @@ UnicodeAPIs.test("transcode/ReferenceTypedArray") { var input: [UInt16] = [ 0x0041, 0x0042 ] var transcoded = [UInt16]() let output: (UInt16) -> Void = { transcoded.append($0) } - transcode(UTF16.self, UTF16.self, input.generate(), output, stopOnError: true) + transcode(UTF16.self, UTF16.self, input.iterator(), output, stopOnError: true) expectEqual(input, transcoded) } @@ -2112,7 +2112,7 @@ class NonContiguousNSString : NSString { convenience init(_ utf8: [UInt8]) { var encoded = [UInt16]() let output: (UInt16) -> Void = { encoded.append($0) } - let iterator = utf8.generate() + let iterator = utf8.iterator() let hadError = transcode(UTF8.self, UTF16.self, iterator, output, stopOnError: true) expectFalse(hadError) @@ -2127,7 +2127,7 @@ class NonContiguousNSString : NSString { convenience init(_ scalars: [UInt32]) { var encoded = [UInt16]() let output: (UInt16) -> Void = { encoded.append($0) } - let iterator = scalars.generate() + let iterator = scalars.iterator() let hadError = transcode(UTF32.self, UTF16.self, iterator, output, stopOnError: true) expectFalse(hadError) @@ -2183,7 +2183,7 @@ StringCookedViews.test("UTF8ForContiguousUTF16") { let expected: [UInt8] = [ 0xca, 0x83 ] + test.encoded let output: (UInt16) -> Void = { backingStorage.append($0) } - var iterator = test.scalars.generate() + var iterator = test.scalars.iterator() transcode(UTF32.self, UTF16.self, iterator, output, stopOnError: false) backingStorage.withUnsafeBufferPointer { @@ -2204,7 +2204,7 @@ StringCookedViews.test("UTF8ForContiguousUTF16") { var expected = [UInt8]() let output: (UInt8) -> Void = { expected.append($0) } var expectedScalars = test.scalarsHead + test.scalarsRepairedTail - var iterator = expectedScalars.generate() + var iterator = expectedScalars.iterator() transcode(UTF32.self, UTF8.self, iterator, output, stopOnError: false) checkUTF8View(expected, subject, test.loc.withCurrentLoc()) @@ -2250,7 +2250,7 @@ StringCookedViews.test("UTF8ForNonContiguousUTF16") { var expected = [UInt8]() let output: (UInt8) -> Void = { expected.append($0) } var expectedScalars = test.scalarsHead + test.scalarsRepairedTail - var iterator = expectedScalars.generate() + var iterator = expectedScalars.iterator() transcode(UTF32.self, UTF8.self, iterator, output, stopOnError: false) var nss = NonContiguousNSString(test.encoded) @@ -2318,7 +2318,7 @@ StringCookedViews.test("UTF16") { var expected = [UInt16]() let output: (UInt16) -> Void = { expected.append($0) } var expectedScalars = test.scalars - var iterator = expectedScalars.generate() + var iterator = expectedScalars.iterator() transcode(UTF32.self, UTF16.self, iterator, output, stopOnError: false) var nss = NonContiguousNSString(test.scalars) @@ -2330,7 +2330,7 @@ StringCookedViews.test("UTF16") { var expected = [UInt16]() let output: (UInt16) -> Void = { expected.append($0) } var expectedScalars = test.scalarsHead + test.scalarsRepairedTail - var iterator = expectedScalars.generate() + var iterator = expectedScalars.iterator() transcode(UTF32.self, UTF16.self, iterator, output, stopOnError: false) checkUTF16View(expected, subject, test.loc.withCurrentLoc()) diff --git a/validation-test/stdlib/UnicodeTrie.swift.gyb b/validation-test/stdlib/UnicodeTrie.swift.gyb index 0732935de4d6e..29fd0b24b3c31 100644 --- a/validation-test/stdlib/UnicodeTrie.swift.gyb +++ b/validation-test/stdlib/UnicodeTrie.swift.gyb @@ -92,7 +92,7 @@ class NonContiguousNSString : NSString { convenience init(_ scalars: [UInt32]) { var encoded: [UInt16] = [] - var g = scalars.generate() + var g = scalars.iterator() let output: (UInt16) -> Void = { encoded.append($0) } let hadError = transcode(UTF32.self, UTF16.self, g, output, stopOnError: true) diff --git a/validation-test/stdlib/UnicodeUTFEncoders.swift b/validation-test/stdlib/UnicodeUTFEncoders.swift index 49f824683b3c3..774a77cc5ffab 100644 --- a/validation-test/stdlib/UnicodeUTFEncoders.swift +++ b/validation-test/stdlib/UnicodeUTFEncoders.swift @@ -112,7 +112,7 @@ class CodecTest { self.encodeBuffer[encodeIndex++] = $0 } - var g = nsEncoded.generate() + var g = nsEncoded.iterator() var decoded: UnicodeScalar var decoder = Codec() switch decoder.decode(&g) {