Skip to content

Commit e4af80d

Browse files
committed
Remove redudant constraints to supress warnings
1 parent f6f3ed0 commit e4af80d

File tree

7 files changed

+10
-59
lines changed

7 files changed

+10
-59
lines changed

stdlib/private/StdlibCollectionUnittest/CheckCollectionInstance.swift.gyb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ public func checkCollection<${genericParam}, C : Collection>(
257257
${TRACE},
258258
resiliencyChecks: CollectionMisuseResiliencyChecks = .all,
259259
sameValue: (${Element}, ${Element}) -> Bool
260-
) where C.Iterator.Element == ${Element},
261-
C.SubSequence : Collection {
260+
) where C.Iterator.Element == ${Element} {
262261

263262
checkForwardCollection(expected, collection, message(),
264263
stackTrace: stackTrace, showFrame: showFrame, file: file, line: line,
@@ -278,7 +277,6 @@ public func check${Traversal}Collection<
278277
resiliencyChecks: CollectionMisuseResiliencyChecks = .all
279278
) where
280279
C.Iterator.Element == ${Element},
281-
C.SubSequence : ${TraversalCollection},
282280
${Element} : Equatable {
283281

284282
check${Traversal}Collection(
@@ -298,8 +296,7 @@ public func check${Traversal}Collection<
298296
resiliencyChecks: CollectionMisuseResiliencyChecks = .all,
299297
sameValue: (${Element}, ${Element}) -> Bool
300298
) where
301-
C.Iterator.Element == ${Element},
302-
C.SubSequence : ${TraversalCollection} {
299+
C.Iterator.Element == ${Element} {
303300

304301
checkOneLevelOf${Traversal}Collection(expected, collection, ${trace},
305302
resiliencyChecks: resiliencyChecks, sameValue: sameValue)
@@ -504,8 +501,7 @@ ${genericParam}, S : ${TraversalCollection}
504501
resiliencyChecks: CollectionMisuseResiliencyChecks = .all,
505502
sameValue: (${Element}, ${Element}) -> Bool
506503
) where
507-
S.Iterator.Element == ${Element},
508-
S.SubSequence : ${TraversalCollection} {
504+
S.Iterator.Element == ${Element} {
509505

510506
let expectedArray = Array(expected)
511507

stdlib/private/StdlibCollectionUnittest/CheckCollectionType.swift.gyb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,9 @@ internal enum _SubSequenceSubscriptOnRangeMode {
471471
%{
472472
from gyb_stdlib_support import collectionForTraversal
473473
def testConstraints(protocol):
474-
if protocol == 'Collection':
475-
subseq_as_collection = 'CollectionWithEquatableElement.SubSequence : Collection,'
476-
else:
477-
subseq_as_collection=''
478474
return '''
479475
C : %(protocol)s,
480476
CollectionWithEquatableElement : %(protocol)s,
481-
%(subseq_as_collection)s
482-
C.SubSequence : %(protocol)s,
483-
C.Indices : %(protocol)s,
484477
CollectionWithEquatableElement.Iterator.Element : Equatable
485478
''' % locals()
486479

@@ -494,6 +487,7 @@ internal enum _SubSequenceSubscriptOnRangeMode {
494487
[CollectionWithEquatableElement.Iterator.Element]
495488
) -> CollectionWithEquatableElement,
496489

490+
497491
wrapValueIntoEquatable: @escaping (
498492
MinimalEquatableValue) -> CollectionWithEquatableElement.Iterator.Element,
499493

stdlib/private/StdlibCollectionUnittest/CheckMutableCollectionType.swift.gyb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ extension TestSuite {
121121
isFixedLengthCollection: Bool,
122122
collectionIsBidirectional: Bool = false
123123
) where
124-
C.SubSequence : MutableCollection,
125-
C.Indices : Collection,
126124
CollectionWithEquatableElement.Iterator.Element : Equatable,
127125
CollectionWithComparableElement.Iterator.Element : Comparable {
128126

@@ -783,8 +781,6 @@ self.test("\(testNamePrefix).partition/InvalidOrderings") {
783781
withUnsafeMutableBufferPointerIsSupported: Bool,
784782
isFixedLengthCollection: Bool
785783
) where
786-
C.SubSequence : BidirectionalCollection & MutableCollection,
787-
C.Indices : BidirectionalCollection,
788784
CollectionWithEquatableElement.Iterator.Element : Equatable,
789785
CollectionWithComparableElement.Iterator.Element : Comparable {
790786

@@ -929,8 +925,6 @@ self.test("\(testNamePrefix).partition/DispatchesThrough_withUnsafeMutableBuffer
929925
withUnsafeMutableBufferPointerIsSupported: Bool,
930926
isFixedLengthCollection: Bool
931927
) where
932-
C.SubSequence : RandomAccessCollection & MutableCollection,
933-
C.Indices : RandomAccessCollection,
934928
CollectionWithEquatableElement.Iterator.Element : Equatable,
935929
CollectionWithComparableElement.Iterator.Element : Comparable {
936930

stdlib/private/StdlibCollectionUnittest/CheckRangeReplaceableCollectionType.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,7 @@ extension TestSuite {
462462
outOfBoundsIndexOffset: Int = 1,
463463
collectionIsBidirectional: Bool = false
464464
) where
465-
C.SubSequence : Collection,
466-
C.Indices : Collection,
467-
CollectionWithEquatableElement.Iterator.Element : Equatable,
468-
CollectionWithEquatableElement.SubSequence : Collection {
465+
CollectionWithEquatableElement.Iterator.Element : Equatable {
469466

470467
var testNamePrefix = testNamePrefix
471468

@@ -1180,8 +1177,6 @@ self.test("\(testNamePrefix).OperatorPlus") {
11801177
resiliencyChecks: CollectionMisuseResiliencyChecks = .all,
11811178
outOfBoundsIndexOffset: Int = 1
11821179
) where
1183-
C.SubSequence : BidirectionalCollection & RangeReplaceableCollection,
1184-
C.Indices : BidirectionalCollection,
11851180
CollectionWithEquatableElement.Iterator.Element : Equatable {
11861181

11871182
var testNamePrefix = testNamePrefix
@@ -1302,8 +1297,6 @@ self.test("\(testNamePrefix).removeLast(n: Int)/whereIndexIsBidirectional/remove
13021297
resiliencyChecks: CollectionMisuseResiliencyChecks = .all,
13031298
outOfBoundsIndexOffset: Int = 1
13041299
) where
1305-
C.SubSequence : RandomAccessCollection & RangeReplaceableCollection,
1306-
C.Indices : RandomAccessCollection,
13071300
CollectionWithEquatableElement.Iterator.Element : Equatable {
13081301

13091302
var testNamePrefix = testNamePrefix

stdlib/private/StdlibCollectionUnittest/CheckRangeReplaceableSliceType.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ extension TestSuite {
3333
collectionIsBidirectional: Bool = false
3434
) where
3535
C.SubSequence == C,
36-
C.Indices : Collection,
3736
CollectionWithEquatableElement.SubSequence == CollectionWithEquatableElement,
3837
CollectionWithEquatableElement.Iterator.Element : Equatable {
3938

@@ -165,7 +164,6 @@ extension TestSuite {
165164
outOfBoundsIndexOffset: Int = 1
166165
) where
167166
C.SubSequence == C,
168-
C.Indices : BidirectionalCollection,
169167
CollectionWithEquatableElement.SubSequence == CollectionWithEquatableElement,
170168
CollectionWithEquatableElement.Iterator.Element : Equatable {
171169

@@ -310,7 +308,6 @@ extension TestSuite {
310308
outOfBoundsIndexOffset: Int = 1
311309
) where
312310
C.SubSequence == C,
313-
C.Indices : RandomAccessCollection,
314311
CollectionWithEquatableElement.SubSequence == CollectionWithEquatableElement,
315312
CollectionWithEquatableElement.Iterator.Element : Equatable {
316313

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,7 @@ public func expectSequenceType<X : Sequence>(_ x: X) -> X
376376
% for Mutable in ['', 'Mutable']:
377377
public func expect${Mutable}CollectionType<X : ${Mutable}Collection>(
378378
_ x: X.Type
379-
) where
380-
// FIXME(ABI)#2 (Associated Types with where clauses): there should be no constraints in
381-
// the 'where' clause, all of these should be required by the protocol.
382-
% if Mutable == '':
383-
X.SubSequence : Collection,
384-
% end
385-
// X.SubSequence.Indices == X.Indices, // FIXME(ABI)#3 (Recursive Protocol Constraints): can't have this constraint now.
386-
X.Indices : Collection {}
379+
) { }
387380
% end
388381

389382
/// A slice is a `Collection` that when sliced returns an instance of
@@ -421,12 +414,7 @@ public func expectCollectionAssociatedTypes<X : Collection>(
421414
indexType: X.Index.Type,
422415
indexDistanceType: X.IndexDistance.Type,
423416
indicesType: X.Indices.Type
424-
) where
425-
// FIXME(ABI)#6 (Associated Types with where clauses): there should be no constraints in
426-
// the 'where' clause, all of these should be required by the protocol.
427-
X.SubSequence : Collection,
428-
// X.SubSequence.Indices == X.Indices, // FIXME(ABI)#7 (Recursive Protocol Constraints): can't have this constraint now.
429-
X.Indices : Collection {}
417+
) { }
430418

431419
/// Check that all associated types of a `BidirectionalCollection` are what we
432420
/// expect them to be.
@@ -437,12 +425,7 @@ public func expectBidirectionalCollectionAssociatedTypes<X : BidirectionalCollec
437425
indexType: X.Index.Type,
438426
indexDistanceType: X.IndexDistance.Type,
439427
indicesType: X.Indices.Type
440-
) where
441-
// FIXME(ABI)#8 (Associated Types with where clauses): there should be no constraints in
442-
// the 'where' clause, all of these should be required by the protocol.
443-
X.SubSequence : BidirectionalCollection,
444-
// X.SubSequence.Indices == X.Indices, // FIXME(ABI)#9 (Recursive Protocol Constraints): can't have this constraint now.
445-
X.Indices : BidirectionalCollection {}
428+
) { }
446429

447430
/// Check that all associated types of a `RandomAccessCollection` are what we
448431
/// expect them to be.
@@ -453,12 +436,7 @@ public func expectRandomAccessCollectionAssociatedTypes<X : RandomAccessCollecti
453436
indexType: X.Index.Type,
454437
indexDistanceType: X.IndexDistance.Type,
455438
indicesType: X.Indices.Type
456-
) where
457-
// FIXME(ABI)#10 (Associated Types with where clauses): there should be no constraints in
458-
// the 'where' clause, all of these should be required by the protocol.
459-
X.SubSequence : RandomAccessCollection,
460-
// X.SubSequence.Indices == X.Indices, // FIXME(ABI)#11 (Recursive Protocol Constraints): can't have this constraint now.
461-
X.Indices : RandomAccessCollection {}
439+
) { }
462440

463441
public struct AssertionResult : CustomStringConvertible {
464442
init(isPass: Bool) {

stdlib/public/core/Collection.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,7 @@ public struct IndexingIterator<
648648
/// an O(*n*) operation.
649649
public protocol Collection : _Indexable, Sequence
650650
where SubSequence: Collection, Indices: Collection,
651-
SubSequence.Index == Index,
652-
SubSequence.Iterator.Element == Iterator.Element
651+
SubSequence.Index == Index
653652
{
654653
/// A type that represents the number of steps between a pair of
655654
/// indices.

0 commit comments

Comments
 (0)