typealias of generic class in Swift
swift, xcode6
Solution
Right now, you can't do this with generics, as you've discovered.
typealias Foo = Array
// Doesn't work: Reference to generic type 'Array' requires argument in <...>
The Swift Programming Language iBook chapter "Type Alias Declaration" doesn't actually state anything about which types cannot be aliased. But it simply looks like that partial types (like generics without placeholders specified) are not allowed.
If you feel that this something Swift should do, file a Radar (bugreport) with Apple.
While researching for this answer, I noticed that the partial type problem not only affects `typealias` but is visible elsewhere as well:
let foo = Array.self
// Doesn't work: Cannot convert the expression's type 'Array<T>.Type' to type 'Array<T>.Type'
// … which is a very confusing error.
var bar: Array.Type
// Doesn't work: Reference to generic type 'Array' requires arguments in <...>
let bar: Array.Type = Array.self
// …/usr/bin/swift: Segmentation fault! :-)
All of these work if you specify the placeholder types:
typealias Foo = Array<Int> // Works
let foo = Array<Int>.self // Works
Problem
I am trying to make a typealias of a generic type class as follows ``` class Cars<T> { ... } typealias SportCars = Cars ``` but I am getting a compile error as follow `Reference to generic type 'Cars' requires argument in <...>`