class BaseClass<T> {
}
class SubClass: BaseClass<Int> {
var test: Optional<T> = .none
}
This code won't compile. It complains that there is no type T
in the subclass scope. Why isn't there support for using generics in subclasses for which a concrete type was provided? This is a problem because if I want to change the type at a later point from say Int
to Double
, then I would have to scan the class's code base to see what usages of Int
resolve to T
and which don't. When I could've just used T
in the first place where intended, and then if I wanted to change the type to something more specific — maybe something that is everything an Int
is but more — then I could've just change the type in the extension definition.