Swift: countElements has invalid type

Originator:rix.rob
Number:rdar://17405344 Date Originated:21-Jun-2014 01:44 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta2 (6A216f)
Classification:Serious Bug Reproducible:Always
 
Summary:
The Swift stdlib specifies countElements’ type as:

func countElements<T>(x: T) -> T.IndexType.DistanceType

Presumably T : Collection, but it’s not specified there, and if copy/paste that into your own Swift file, lo and behold the compiler complains: IndexType is not a member of type T. This is confusing and misleading. It should presumably instead be:

func countElements<T : Collection>(x: T) -> T.IndexType.DistanceType


Steps to Reproduce:
Look at countElements.

Expected Results:
I expected it would have a valid type.

Actual Results:
It did not.

Regression:
N/A

Notes:
N/A

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!