Skip to content

Commit 408e8c7

Browse files
author
Russ Bishop
committed
Remove RandomAccess overloads and types
1 parent 1afa93b commit 408e8c7

File tree

3 files changed

+5
-61
lines changed

3 files changed

+5
-61
lines changed

stdlib/public/core/Filter.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public func > <Base : Collection>(
165165
// collapsed into one `LazyFilterCollection` using conditional conformances.
166166
// Maybe even combined with `LazyFilterSequence`.
167167

168-
% for Traversal in ['Forward', 'Bidirectional', 'RandomAccess']:
168+
% for Traversal in ['Forward', 'Bidirectional']:
169169
% Self = "LazyFilter" + collectionForTraversal(Traversal)
170170
% Slice = sliceTypeName(traversal=Traversal, mutable=False, rangeReplaceable=False)
171171

@@ -244,7 +244,7 @@ public struct ${Self}<
244244
i = LazyFilterIndex(base: index)
245245
}
246246

247-
% if Traversal == 'Bidirectional' or Traversal == 'RandomAccess':
247+
% if Traversal == 'Bidirectional':
248248
@warn_unused_result
249249
public func index(before i: Index) -> Index {
250250
var i = i
@@ -315,7 +315,7 @@ extension LazySequenceProtocol {
315315
}
316316
}
317317

318-
% for Traversal in ['Forward', 'Bidirectional', 'RandomAccess']:
318+
% for Traversal in ['Forward', 'Bidirectional']:
319319

320320
extension LazyCollectionProtocol
321321
where

stdlib/public/core/FlatMap.swift

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,28 +127,3 @@ extension LazyCollectionProtocol
127127
return self.map(transform).filter { $0 != nil }.map { $0! }
128128
}
129129
}
130-
131-
extension LazyCollectionProtocol
132-
where
133-
Self : RandomAccessCollection,
134-
Elements : RandomAccessCollection
135-
{
136-
/// Returns a `LazyMapRandomAccessCollection` containing the concatenated non-nil
137-
/// results of mapping transform over this collection. The elements of
138-
/// the result are computed lazily, each time they are read.
139-
///
140-
/// Use this method to receive only nonoptional values when your
141-
/// transformation produces an optional value.
142-
///
143-
/// - Parameter transform: A closure that accepts an element of this
144-
/// collection as its argument and returns an optional value.
145-
public func flatMap<U>(
146-
_ transform: (Self.Elements.Iterator.Element) -> U?
147-
) -> LazyMapRandomAccessCollection<
148-
LazyFilterRandomAccessCollection<
149-
LazyMapRandomAccessCollection<Self.Elements, U?>>,
150-
U
151-
> {
152-
return self.map(transform).filter { $0 != nil }.map { $0! }
153-
}
154-
}

validation-test/stdlib/Lazy.swift.gyb

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,20 +1161,6 @@ tests.test("LazyFilterBidirectionalCollection/AssociatedTypes") {
11611161
indicesType: DefaultBidirectionalIndices<Subject>.self)
11621162
}
11631163

1164-
tests.test("LazyFilterRandomAccessCollection/AssociatedTypes") {
1165-
typealias Base = MinimalRandomAccessCollection<OpaqueValue<Int>>
1166-
typealias Subject = LazyFilterRandomAccessCollection<Base>
1167-
expectRandomAccessCollectionAssociatedTypes(
1168-
collectionType: Subject.self,
1169-
iteratorType: LazyFilterIterator<Base.Iterator>.self,
1170-
// FIXME(ABI): SubSequence should be `LazyFilterRandomAccessCollection<Base.Slice>`.
1171-
subSequenceType: RandomAccessSlice<Subject>.self,
1172-
indexType: LazyFilterIndex<Base>.self,
1173-
indexDistanceType: Base.IndexDistance.self,
1174-
indicesType: DefaultRandomAccessIndices<Subject>.self)
1175-
}
1176-
1177-
11781164
tests.test("lazy.filter/TypeInference") {
11791165
let baseArray: [OpaqueValue<Int>] = (0..<10).map(OpaqueValue.init)
11801166
do {
@@ -1204,7 +1190,7 @@ tests.test("lazy.filter/TypeInference") {
12041190
var filtered = MinimalRandomAccessCollection(elements: baseArray)
12051191
.lazy.filter { _ in true }
12061192
expectType(
1207-
LazyFilterRandomAccessCollection<
1193+
LazyFilterBidirectionalCollection<
12081194
MinimalRandomAccessCollection<OpaqueValue<Int>>
12091195
>.self,
12101196
&filtered)
@@ -1297,22 +1283,5 @@ do {
12971283
}
12981284
}
12991285

1300-
% for Traversal in TRAVERSALS:
1301-
% TraversalCollection = collectionForTraversal(Traversal)
1302-
tests.test("${TraversalCollection}/lazy/flatMap") {
1303-
let sample = (0..<100)
1304-
let expected = sample.filter { $0 % 3 != 0 }.map { String($0) }
1305-
let base = Minimal${TraversalCollection}(elements: sample).lazy
1306-
1307-
var calls = 0
1308-
let mapped = sample.lazy.flatMap { (x) -> String? in
1309-
calls += 1
1310-
return x % 3 != 0 ? String(x) : nil
1311-
}
1312-
expectEqual(0, calls, "unexpected eagerness in \(base.dynamicType).flatMap")
1313-
1314-
checkSequence(expected, mapped, resiliencyChecks: .none)
1315-
}
1316-
%end
1317-
13181286
runAllTests()
1287+

0 commit comments

Comments
 (0)