Covariance and Contravariance

Such a change is said to be either covariant or contravariant. If the argument is made more general, then it is said to be covariant. If the argument is made more restrictive, then it is said to be contravariant.

Both covariant and contravariant changes interfer with substitutability, and can destroy the is-a relation. The semantics of both are very tricky. For this reason, most language forbid both.

[audio] [real] Text to accompany slide17, in Chapter 12 of An Introduction to Object-Oriented Programming