Swift: Compiler error for extensions on Generic Types

Originator:davelee.com
Number:rdar://17220438 Date Originated:2014-06-07
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
 
Summary:
According to the Swift language specification (in "The Swift Programming Language"), it should be possible to create an extension on Generic Types. The extension grammar states that an extension takes an "type-identifier", which can include a "generic-argument-clause".

Currently, this is not possible, resulting in a compiler error (see below). This fails with both Standard Library types, and also user defined types.

Even looking at the Swift standard library, it shows numerous extensions on Generic Types, some particularly notable examples are Array and Dictionary.

Steps to Reproduce:
1. Install Xcode6-Beta
2. Create New Swift File
3. Add the following:

// Alternatively:
// extension T[] { }
extension Array<T> {
}

4. Create another New Swift File
5. Add the following:

struct Foo<T> {
}

extension Foo<T> {
}


Expected Results:
I expect for this to compile. Otherwise, the type of extensions one could add to a Generic Type would be very limited.

Actual Results:
error: use of undeclared type 'T'

Version:
Version 6.0 (6A215l)

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!