re: Pains of Java generics solved in Kotlin VIEW POST

re: I think you're missing a point here. Uncle Bob described this problem, but he used List<Shape> and List<Circle> I believe. Where Shape ...

With all respect I think you've missed the point of the article. Of course it does not apply to Lists, since they both produce and consume objects. It could apply to immutable lists, where you cannot add/set items, only get.

My point was to show that classes with generic types that are used in producer role are not detected by Java compiler as safe to cast, when covariant types are used.


I see. Thanks for the clarification. I'm still not sure that this technique is really safe and won't be abused in some very unobvious ways, but that's completely different story. :)

code of conduct - report abuse