I also ran up against another annoying bug/oversight/v0.1ism : You can't inherit from a generic class without becoming generic yourself. So, even if you fully instantiate your parent's type information, you have to be generic as well! For example:
class Foo<T> { ... }
class Bar : Foo<String> { ... }
You'd expect Bar to be a non-generic type, but this throws a compiler error. You have to declare: class Foo<T> { ... }
class Bar<String> : Foo<String> { ... }
Which seems just odd. The best workaround I've found thus far is class Foo<T> { ... }
class BarClass<String> : Foo<String> { ... }
typealias Bar = BarClass<String>
Bleh. I've filed a radar against this one - it seems like an annoying oversight, even for this early version.`class Bar<String> : Foo<String>` is exactly the same as `class Bar<T> : Foo<T>`. The identifier `String` in declaration of `Bar` does not refer to built-in type String, it is a tag for any type.
In other words, you CAN have `Bar<Int>`, `Bar<Float>` and `Bar<everything else>` after using that declaration of `Bar`.
Indeed, calling it Bar<String> seems really weird to me. Usually, in a declaration, the thing inside the angle brackets is a the name of a parameter, which can assume various values at runtime:
class Foo<T>
But in the subclass, it's the name of a type: class Bar<String>
Essentially, one is a declaration, and the other is an expression. Like and l-value and an r-value. I don't think i've ever seen a language which allows both of those in the same place.The fact that an instance of A is assignment compatible with a location of type B does not imply that a class of type A is assignment compatible with a location of type class of B.
This is not the case for languages like C#, Java, C++ etc. (despite those languages not having class types); if a subclass does not define all the constructors of its ancestor class, the subclass is not a "drop-in replacement".
Delphi does have class value polymorphism that mirrors instance polymorphism, and it can be a source of confusion, not to mention type holes. For A inheriting from B, you can construct a value of type A using a constructor of B if you assign A to a location of type class of B; A's constructor won't run, and its assumptions and invariants won't necessarily hold. It's one of several problems that makes designing robust classes in Delphi awkward.
class NodeList extends List<Node> { ... }
So did I! A few more related links if you're interested in this question:
http://schani.wordpress.com/2014/06/11/associated-types-cons...
http://www.artima.com/weblogs/viewpost.jsp?thread=270195 (this is about Scala, but Swift somewhat follows Scala with this design)
https://groups.google.com/forum/#!topic/swift-language/3Ptyd...