CollectionType.SubSequence is not a CollectionType

Originator:robnapier
Number:rdar://21941243 Date Originated:22-Jul-2015 11:04 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Swift 2b4
Classification:Other Bug Reproducible:Not Applicable
 
According to the CollectionType documentation:

    /// - Note: this associated type appears as a requirement in
    ///   `SequenceType`, but is restated here with stricter
    ///   constraints: in a `CollectionType`, the `SubSequence` should
    ///   also be a `CollectionType`.
    typealias SubSequence : Indexable, SequenceType = Slice<Self>

However, CollectionType.SubSequence is not a CollectionType. It is only an Indexable SequenceType. Moreover, SubSequence is not a requirement in SequenceType.

This means the following code, which I would expect to compile, fails because Seq.SubSequence is not guaranteed to be a CollectionType:

func count<Seq: CollectionType>(xs: Seq) -> Int {
    guard !xs.isEmpty else { return 0 }
    return 1 + count(dropFirst(xs)) // Cannot find an overload for ‘count’ that accepts an argument list of type ‘(Seq.SubSequence)’
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!