I was reading through the Hacklang docs on Collections, and came across this curious definition [paraphrased slightly]:
interface KeyedIterable<Tk, Tv> ...
interface ConstVector<+Tv> implements KeyedIterable<int, Tv> ...
Of course, KeyedIterable
must be read-only with respect to Tv, and indeed it is since its methods cannot modify its type. It could be specified to be covariant on at least Tv
, but isn't.
I was wondering what impetus there could be to do this?
Edit: I read the definition wrong, KeyedIterable
is actually defined as KeyedIterable<Tk, +Tv>
, so this definition makes perfect sense. I'm just realizing now that it's not so much "should or should not", but rather "this is never possible".