Type-safe covariance: Competent compilers can catch all catcalls

Goals of expressiveness and flexibility in typed object-oriented programming suggest a “covariant” type policy, where routine redefinitions can change the types of both arguments and results in the same direction as the inheritance hierarchy. Unfortunately, a careless covariant policy, when combined with polymorphism, genericity and dynamic binding — other O-O mechanisms that are just as fundamental — may lead to run-time type violations known as catcalls. We present a new solution to this problem, resulting from recent advances in the Eiffel language, which enables compilers to spot all potential catcalls and forces programmer to resolve them. The resulting language rules statically guarantee type safety; they only require local analysis and are easy to explain to programmers.

[1]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[2]  Luca Cardelli,et al.  Basic Polymorphic Typechecking , 1987, Sci. Comput. Program..

[3]  Luigi Liquori,et al.  Match-O, a dialect of Eiffel with match-types , 2000, Proceedings 37th International Conference on Technology of Object-Oriented Languages and Systems. TOOLS-Pacific 2000.

[4]  Bertrand Meyer,et al.  Object-Oriented Software Construction, 2nd Edition , 1997 .

[5]  Paul Reynolds,et al.  Automating delegation in class-based languages , 2000, Proceedings. 34th International Conference on Technology of Object-Oriented Languages and Systems - TOOLS 34.

[6]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Inf. Comput..

[7]  John C. Mitchell,et al.  F-bounded polymorphism for object-oriented programming , 1989, FPCA.

[8]  Franz Weber Getting Class Correctness and System Correctness Equivalent (How to get covariance right) , 1992, TOOLS.

[9]  Giuseppe Castagna,et al.  Covariance and contravariance: conflict without a cause , 1995, TOPL.

[10]  William R. Cook,et al.  A Proposal for Making Eiffel Type-Safe , 1989, Comput. J..