by ootachi · 14y ago · 0 comments
I think the mistake the Java designers made here was going with use-site variance instead of definition-site variance.
On the other hand, sometimes I think an unsound type system with List<String> being a subtype of List<Object> would be better than what we have today, for pragmatic reasons. Of course, I think this makes me a non-type-theorist, as what I'm saying is considered heresy in some circles [1].
[1] http://lambda-the-ultimate.org/node/4377 (search for unsound).
On the other hand, if your structure is immutable it would probably work.