3 ms·
> if A is a subtype of B then List[A] should be considered a subtype of List[B] Well, careful -- I'm sure you know this by your name, but the naive treatment o
by Twisol 6y ago
> if A is a subtype of B then List[A] should be considered a subtype of List[B]
Well, careful -- I'm sure you know this by your name, but the naive treatment of Java's native array type as A[] <: B[] when A <: B leads to well-known soundness issues.
Fundamentally that's because you can both read and write to Java's arrays; if you assume arrays are read-only then A[] <: B[] is indeed sound.
- contravariant 6y agoYeah I was thinking of the read only kind, you do need to be a bit careful when your objects are mutable ;-)