Re:The Unsound Playground: Java and Scala's Type Systems are...
by prodigal_erik on Sunday November 27, 2016 @07:45PM
(#13052631)
What we need is
listContaining(Dog) isa listContaining(Animal)
listAccepting(Animal) isa listAccepting(Dog)
Re:The Unsound Playground: Java and Scala's Type Systems are...
by STRML on Sunday November 27, 2016 @09:11PM
(#13052944)
Which is precisely the idea of covariant getters / contravariant setters in some sounder languages.
Re:The Unsound Playground: Java and Scala's Type Systems are...
by Kreeg on Monday November 28, 2016 @06:36AM
(#13054789)
IIRC, Scala has covariant/contravariant generics
(apologies for the bad terminology, I'm not too familiar with the details)
Re:The Unsound Playground: Java and Scala's Type Systems are...
by Groxx on Wednesday November 30, 2016 @12:28AM
(#13068695)
support for "<? extends X>" and "<? super X>" is supporting covariant / contravariant. invariant would be "<x>".
basically. the same concept applies in a number of areas, with varying support (e.g. Java doesn't support contravariance in its method overloading: http://stackoverflow.com/a/2501513/16295 )
Just because D isa B it does not mean list(D) isa list(B).