wiki Contravariant_method_argument_type says overriding method has the subtyping rule as function type, but no language except one support contravariant argument type. I also not able to come up with any idea of benefit to use that.
example:
class AnimalShelter {
Animal getAnimalForAdoption() { ... }
void putAnimal(Animal animal) { ... }
}
class CatShelter extends AnimalShelter {
@Overriding
Cat getAnimalForAdoption() { return new Cat(); }
@Overriding
void putAnimal(Object animal) { … }
}
My question is:
- Is contravariant argument type of overriding method any of good use? if yes, where it is?
- Is method a function? Why Scala has different rule for function type and overriding method type?