Do cows eat grass?

The topic is the covariance of non-generic parameters in the languages PL/SQL, C ++, Eiffel, Java, Scala, Kotlin (except PL/SQL, the order of other languages is the order of their occurrence).


In the example, covariance is attempted to be applied to two related superclass/subclass pairs. In this particular case these are the classes Animal/Cow and Animal_food/Cow_food.

In one procedure of the Animal class there is a parameter of the Animal_food class. Can we (in the languages listed above) in the Cow subclass make an overridden procedure that uses the Cow_food class instead of the Animal_food class? One language had this feature from the beginning (late 80’s), but this feature allowed a runtime error, which was resolved in 2014. But there is another language (among the languages listed above) that makes this possible, in a different way.

Note: the use of generic parameters (and their covariance) is not the “right” solution (it is a solution, but with major practical drawbacks).