Dominic Grostate wrote on 29/04/2016 16:59:
After reading your email again, I find myself agreeing. This is
because I don't consider List<Integer> to be a subtype of List<Number>.
LinkedList<Number> would be a subtype of List<Number>, but inheritance
doesn't really extend any further beyond that, for the reason you have
illustrated.
Precisely, the rules for variance of the type parameter <Number> are not
the same as the rules for variance of the generic class List itself. The
exact variance that you want is different in different situations, so
the safest assumption the language can make is to make the type
parameter invariant by default, and then possibly have a syntax for you
to state that you want covariance or contravariance in specific situations.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php