Skip to content

[stdlib] Conditional gardening [NFC] #13191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions stdlib/public/core/Indices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@ extension Collection where Indices == DefaultIndices<Self> {
}
}

public typealias DefaultBidirectionalIndices<T: BidirectionalCollection> = DefaultIndices<T>
public typealias DefaultRandomAccessIndices<T: RandomAccessCollection> = DefaultIndices<T>
@available(*, deprecated, renamed: "DefaultIndices")
public typealias DefaultBidirectionalIndices<T> = DefaultIndices<T> where T : BidirectionalCollection
@available(*, deprecated, renamed: "DefaultIndices")
public typealias DefaultRandomAccessIndices<T> = DefaultIndices<T> where T : RandomAccessCollection
14 changes: 4 additions & 10 deletions stdlib/public/core/RangeReplaceableCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public typealias RangeReplaceableIndexable = RangeReplaceableCollection
/// `replaceSubrange(_:with:)` with an empty collection for the `newElements`
/// parameter. You can override any of the protocol's required methods to
/// provide your own custom implementation.
public protocol RangeReplaceableCollection: Collection
where SubSequence: RangeReplaceableCollection
{
public protocol RangeReplaceableCollection : Collection
where SubSequence : RangeReplaceableCollection {
// FIXME(ABI): Associated type inference requires this.
associatedtype SubSequence = Slice<Self>

Expand Down Expand Up @@ -782,9 +781,7 @@ extension RangeReplaceableCollection {
}

extension RangeReplaceableCollection
where
Self : BidirectionalCollection,
SubSequence == Self {
where Self : BidirectionalCollection, SubSequence == Self {

@_inlineable
public mutating func _customRemoveLast() -> Element? {
Expand Down Expand Up @@ -854,10 +851,7 @@ extension RangeReplaceableCollection where Self : BidirectionalCollection {
// FIXME: swift-3-indexing-model: file a bug for the compiler?
/// Ambiguity breakers.
extension RangeReplaceableCollection
where
Self : BidirectionalCollection,
SubSequence == Self
{
where Self : BidirectionalCollection, SubSequence == Self {
/// Removes and returns the last element of the collection.
///
/// The collection must not be empty.
Expand Down
29 changes: 14 additions & 15 deletions stdlib/public/core/Slice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ extension Slice: MutableCollection where Base: MutableCollection {

extension Slice: RandomAccessCollection where Base: RandomAccessCollection { }

extension Slice: RangeReplaceableCollection where Base: RangeReplaceableCollection {
extension Slice: RangeReplaceableCollection
where Base: RangeReplaceableCollection {
@_inlineable // FIXME(sil-serialize-all)
public init() {
self._base = Base()
Expand Down Expand Up @@ -354,7 +355,7 @@ extension Slice: RangeReplaceableCollection where Base: RangeReplaceableCollecti
}

extension Slice
where Base: RangeReplaceableCollection, Base: BidirectionalCollection {
where Base: RangeReplaceableCollection, Base: BidirectionalCollection {

@_inlineable // FIXME(sil-serialize-all)
public mutating func replaceSubrange<C>(
Expand Down Expand Up @@ -476,27 +477,25 @@ where Base: RangeReplaceableCollection, Base: BidirectionalCollection {
}

@available(*, deprecated, renamed: "Slice")
public typealias BidirectionalSlice<T> = Slice<T> where T: BidirectionalCollection
public typealias BidirectionalSlice<T> = Slice<T> where T : BidirectionalCollection
@available(*, deprecated, renamed: "Slice")
public typealias RandomAccessSlice<T> = Slice<T> where T: RandomAccessCollection
public typealias RandomAccessSlice<T> = Slice<T> where T : RandomAccessCollection
@available(*, deprecated, renamed: "Slice")
public typealias RangeReplaceableSlice<T> = Slice<T> where T: RangeReplaceableCollection
public typealias RangeReplaceableSlice<T> = Slice<T> where T : RangeReplaceableCollection
@available(*, deprecated, renamed: "Slice")
public typealias RangeReplaceableBidirectionalSlice<T> = Slice<T> where T: RangeReplaceableCollection, T: BidirectionalCollection
public typealias RangeReplaceableBidirectionalSlice<T> = Slice<T> where T : RangeReplaceableCollection & BidirectionalCollection
@available(*, deprecated, renamed: "Slice")
public typealias RangeReplaceableRandomAccessSlice<T> = Slice<T> where T: RangeReplaceableCollection, T: RandomAccessCollection
public typealias RangeReplaceableRandomAccessSlice<T> = Slice<T> where T : RangeReplaceableCollection & RandomAccessCollection

@available(*, deprecated, renamed: "Slice")
public typealias MutableSlice<T: MutableCollection> = Slice<T>
public typealias MutableSlice<T> = Slice<T> where T : MutableCollection
@available(*, deprecated, renamed: "Slice")
public typealias MutableBidirectionalSlice<T: MutableCollection> = Slice<T> where T: BidirectionalCollection
public typealias MutableBidirectionalSlice<T> = Slice<T> where T : MutableCollection & BidirectionalCollection
@available(*, deprecated, renamed: "Slice")
public typealias MutableRandomAccessSlice<T: MutableCollection> = Slice<T> where T: RandomAccessCollection
public typealias MutableRandomAccessSlice<T> = Slice<T> where T : MutableCollection & RandomAccessCollection
@available(*, deprecated, renamed: "Slice")
public typealias MutableRangeReplaceableSlice<T: MutableCollection> = Slice<T> where T: RangeReplaceableCollection
public typealias MutableRangeReplaceableSlice<T> = Slice<T> where T : MutableCollection & RangeReplaceableCollection
@available(*, deprecated, renamed: "Slice")
public typealias MutableRangeReplaceableBidirectionalSlice<T: MutableCollection> = Slice<T> where T: RangeReplaceableCollection, T: BidirectionalCollection
public typealias MutableRangeReplaceableBidirectionalSlice<T> = Slice<T> where T : MutableCollection & RangeReplaceableCollection & BidirectionalCollection
@available(*, deprecated, renamed: "Slice")
public typealias MutableRangeReplaceableRandomAccessSlice<T: MutableCollection> = Slice<T> where T: RangeReplaceableCollection, T: RandomAccessCollection


public typealias MutableRangeReplaceableRandomAccessSlice<T> = Slice<T> where T : MutableCollection & RangeReplaceableCollection & RandomAccessCollection
2 changes: 1 addition & 1 deletion test/stdlib/collection-combinatorics.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ struct ${indexLabel}${mutable}${rangeReplaceable}${capability}Butt
// This type alias is required for some random-access collections with
// a custom index type -- without it the default implementation for
// `indices` doesn't attach.
typealias Indices = DefaultRandomAccessIndices<${indexLabel}${mutable}${rangeReplaceable}${capability}Butt>
typealias Indices = DefaultIndices<${indexLabel}${mutable}${rangeReplaceable}${capability}Butt>
% end
}