[Swift] Collection protocol definition incomplete

Originator:janoschhildebrand
Number:rdar://17380532 Date Originated:19-Jun-2014
Status:Duplicate of 19895265 (Closed) Resolved:02-Jul-2014
Product:Developer Tools Product Version:Xcode 6 - Beta 2 (6A216f)
Classification:Other Bug Reproducible:Always
 
Summary:
The collection protocol from the Swift standard library is shown to be defined as follows when viewed by cmd-clicking it in Xcode:

protocol Collection : Sequence {
    subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}

However to implement the protocol, properties for 'startIndex' and 'endIndex' need to be defined.

If a collection is implemented only satisfying the protocol as shown above, the Swift compiler produces the following errors:


Swift._Collection:3:7: note: protocol requires property 'startIndex' with type 'C.IndexType'
  var startIndex: IndexType { get }


Swift._Collection:4:7: note: protocol requires property 'endIndex' with type 'C.IndexType'
  var endIndex: IndexType { get }


Hence the Collection protocol from the Swift module should be shown to be defined as follows:

protocol Collection : Sequence {
    typealias Self.IndexType

    subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }

  var startIndex: IndexType { get }
  var endIndex: IndexType { get }
}

Steps to Reproduce:
1. Open Xcode
2. Create a new Swift playground
3. Write 'Collection' in the playground
4. cmd-click on 'Collection'

Expected Results:
The collection protocol should be shown as:

protocol Collection : Sequence {
    typealias Self.IndexType

    subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }

    var startIndex: IndexType { get }
    var endIndex: IndexType { get }
}

Actual Results:
The protocol is shown as:

protocol Collection : Sequence {
    subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}

Version:
Xcode 6 - Beta 2 (6A216f)
Swift version 1.0 (swift-600.0.34.4.8)
OS X 10.10 (14A261i)

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!