Skip to content

Commit d957041

Browse files
committed
revert changes to stdlib
1 parent c03b14e commit d957041

7 files changed

+73
-23
lines changed

stdlib/public/core/ArrayBufferProtocol.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
internal protocol _ArrayBufferProtocol
1717
: MutableCollection, RandomAccessCollection {
1818

19-
associatedtype Indices = CountableRange<Int>
19+
associatedtype Indices
20+
// FIXME(ABI) (Revert Where Clauses): Remove this conformance
21+
: RandomAccessCollection
22+
= CountableRange<Int>
2023

2124
/// The type of elements stored in the buffer.
2225
associatedtype Element

stdlib/public/core/BidirectionalCollection.swift

+11-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public protocol _BidirectionalIndexable : _Indexable {
6666
/// - If `i > c.startIndex && i <= c.endIndex`
6767
/// `c.index(after: c.index(before: i)) == i`.
6868
public protocol BidirectionalCollection : _BidirectionalIndexable, Collection
69-
where SubSequence: BidirectionalCollection, Indices: BidirectionalCollection {
69+
// FIXME(ABI) (Revert Where Clauses): Restore these
70+
// where SubSequence: BidirectionalCollection, Indices: BidirectionalCollection
71+
{
7072

7173
// TODO: swift-3-indexing-model - replaces functionality in BidirectionalIndex
7274
/// Returns the position immediately before the given index.
@@ -84,11 +86,17 @@ where SubSequence: BidirectionalCollection, Indices: BidirectionalCollection {
8486

8587
/// A sequence that can represent a contiguous subrange of the collection's
8688
/// elements.
87-
associatedtype SubSequence = BidirectionalSlice<Self>
89+
associatedtype SubSequence
90+
// FIXME(ABI) (Revert Where Clauses): Remove these conformances
91+
: _BidirectionalIndexable, Collection
92+
= BidirectionalSlice<Self>
8893

8994
/// A type that represents the indices that are valid for subscripting the
9095
/// collection, in ascending order.
91-
associatedtype Indices = DefaultBidirectionalIndices<Self>
96+
associatedtype Indices
97+
// FIXME(ABI) (Revert Where Clauses): Remove these conformances
98+
: _BidirectionalIndexable, Collection
99+
= DefaultBidirectionalIndices<Self>
92100

93101
/// The indices that are valid for subscripting the collection, in ascending
94102
/// order.

stdlib/public/core/Collection.swift

+19-9
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,8 @@ public struct IndexingIterator<
647647
/// count the number of contained elements, accessing its `count` property is
648648
/// an O(*n*) operation.
649649
public protocol Collection : _Indexable, Sequence
650-
where SubSequence: Collection, Indices: Collection,
651-
SubSequence.Index == Index,
652-
SubSequence.Iterator.Element == Iterator.Element
650+
// FIXME(ABI) (Revert Where Clauses): Restore these
651+
// where SubSequence: Collection, Indices: Collection,
653652
{
654653
/// A type that represents the number of steps between a pair of
655654
/// indices.
@@ -676,9 +675,15 @@ where SubSequence: Collection, Indices: Collection,
676675
/// This associated type appears as a requirement in the `Sequence`
677676
/// protocol, but it is restated here with stricter constraints. In a
678677
/// collection, the subsequence should also conform to `Collection`.
679-
associatedtype SubSequence = Slice<Self>
680-
where Iterator.Element == SubSequence.Iterator.Element,
681-
SubSequence.SubSequence == SubSequence
678+
associatedtype SubSequence
679+
// FIXME(ABI) (Revert Where Clauses): remove these conformances:
680+
: _IndexableBase, Sequence
681+
= Slice<Self>
682+
where SubSequence.SubSequence == SubSequence
683+
// FIXME(ABI) (Revert Where Clauses): and this where clause:
684+
, Iterator.Element == SubSequence.Iterator.Element
685+
, SubSequence.Index == Index
686+
682687

683688
// FIXME(ABI)#98 (Recursive Protocol Constraints):
684689
// FIXME(ABI)#99 (Associated Types with where clauses):
@@ -740,10 +745,15 @@ where SubSequence: Collection, Indices: Collection,
740745

741746
/// A type that represents the indices that are valid for subscripting the
742747
/// collection, in ascending order.
743-
associatedtype Indices = DefaultIndices<Self>
744-
where Indices.Iterator.Element == Index,
748+
associatedtype Indices
749+
// FIXME(ABI) (Revert Where Clauses): Remove these two conformances
750+
: _Indexable, Sequence
751+
= DefaultIndices<Self>
752+
where Indices.Iterator.Element == Index,
745753
Indices.Index == Index
746-
754+
// FIXME(ABI) (Revert Where Clauses): Remove this where clause
755+
, Indices.SubSequence == Indices
756+
747757
// FIXME(ABI)#100 (Recursive Protocol Constraints):
748758
// associatedtype Indices : Collection
749759
// where

stdlib/public/core/ExistentialCollection.swift.gyb

+14-3
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,21 @@ internal class _AnyRandomAccessCollectionBox<Element>
423423
% assert False, 'Unknown kind'
424424
% end
425425

426+
427+
426428
@_fixed_layout
427429
@_versioned
428430
internal final class _${Kind}Box<S : ${Kind}> : _Any${Kind}Box<S.Iterator.Element>
429-
% if Kind == 'Sequence':
430431
where
431432
S.SubSequence : ${Kind},
433+
// FIXME(ABI) (Revert Where Clauses): apply all this only to Sequence:
434+
% if Kind == 'Sequence':
432435
S.SubSequence.Iterator.Element == S.Iterator.Element,
433436
S.SubSequence.SubSequence == S.SubSequence
437+
// FIXME(ABI) (Revert Where Clauses): remove this else clause:
438+
% else:
439+
S.SubSequence.Indices : ${Kind},
440+
S.Indices : ${Kind}
434441
% end
435442
{
436443
internal typealias Element = S.Iterator.Element
@@ -1035,8 +1042,12 @@ public struct ${Self}<Element>
10351042
@_inlineable
10361043
public init<C : ${SubProtocol}>(_ base: C)
10371044
where
1038-
// FIXME(ABI)#101 (Associated Types with where clauses): these constraints should be applied to
1039-
// associated types of Collection.
1045+
// FIXME(ABI) (Revert Where Clauses): remove next 3 lines
1046+
C.SubSequence : ${SubProtocol},
1047+
C.SubSequence.Indices : ${SubProtocol},
1048+
C.Indices : ${SubProtocol},
1049+
// FIXME(ABI)#101 (Associated Types with where clauses): these constraints
1050+
// should be applied to associated types of Collection.
10401051
C.SubSequence.Iterator.Element == Element
10411052
{
10421053
// Traversal: ${Traversal}

stdlib/public/core/Mirror.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ public struct Mirror {
214214
children: C,
215215
displayStyle: DisplayStyle? = nil,
216216
ancestorRepresentation: AncestorRepresentation = .generated
217-
) where C.Iterator.Element == Child {
217+
) where C.Iterator.Element == Child
218+
// FIXME(ABI) (Revert Where Clauses): Remove these
219+
, C.SubSequence : Collection, C.SubSequence.Indices : Collection, C.Indices : Collection
220+
{
218221

219222
self.subjectType = Subject.self
220223
self._makeSuperclassMirror = Mirror._superclassIterator(
@@ -261,7 +264,10 @@ public struct Mirror {
261264
unlabeledChildren: C,
262265
displayStyle: DisplayStyle? = nil,
263266
ancestorRepresentation: AncestorRepresentation = .generated
264-
) {
267+
)
268+
// FIXME(ABI) (Revert Where Clauses): Remove these two clauses
269+
where C.SubSequence : Collection, C.Indices : Collection
270+
{
265271

266272
self.subjectType = Subject.self
267273
self._makeSuperclassMirror = Mirror._superclassIterator(

stdlib/public/core/MutableCollection.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@ public protocol _MutableIndexable : _Indexable {
197197
/// a[i] = x
198198
/// let y = x
199199
public protocol MutableCollection : _MutableIndexable, Collection
200-
where SubSequence: MutableCollection {
201-
associatedtype SubSequence = MutableSlice<Self>
200+
// FIXME(ABI) (Revert Where Clauses): restore this:
201+
// where SubSequence: MutableCollection
202+
{
203+
associatedtype SubSequence
204+
// FIXME(ABI) (Revert Where Clauses): remove this conformance:
205+
: Collection
206+
= MutableSlice<Self>
202207

203208
/// Accesses the element at the specified position.
204209
///

stdlib/public/core/RandomAccessCollection.swift

+10-3
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,22 @@ public protocol _RandomAccessIndexable : _BidirectionalIndexable {
4848
/// `distance(from:to:)` methods with O(1) efficiency.
4949
public protocol RandomAccessCollection :
5050
_RandomAccessIndexable, BidirectionalCollection
51-
where SubSequence: RandomAccessCollection, Indices: RandomAccessCollection
51+
// FIXME(ABI) (Revert Where Clauses): Restore this:
52+
// where SubSequence: RandomAccessCollection, Indices: RandomAccessCollection
5253
{
5354
/// A collection that represents a contiguous subrange of the collection's
5455
/// elements.
55-
associatedtype SubSequence = RandomAccessSlice<Self>
56+
associatedtype SubSequence
57+
// FIXME(ABI) (Revert Where Clauses): Remove these two constraints:
58+
: _RandomAccessIndexable, BidirectionalCollection
59+
= RandomAccessSlice<Self>
5660

5761
/// A type that represents the indices that are valid for subscripting the
5862
/// collection, in ascending order.
59-
associatedtype Indices = DefaultRandomAccessIndices<Self>
63+
associatedtype Indices
64+
// FIXME(ABI) (Revert Where Clauses): Remove these two constraints:
65+
: _RandomAccessIndexable, BidirectionalCollection
66+
= DefaultRandomAccessIndices<Self>
6067

6168
/// The indices that are valid for subscripting the collection, in ascending
6269
/// order.

0 commit comments

Comments
 (0)