Type-Safe Compilation of Covariant Specialization: A Practical Case

by John Boyland and Giuseppe Castagna

Abstract

Despite its lack of type safety, some typed object-oriented languages use covariant specialization for methods. In this work, we show how one may modify the semantics of languages that use covariant specialization in order to improve their type safety. We demonstrate our technique using O2, a strongly and statically typed object-oriented database programming language which uses covariant specialization. We propose a modification to the O2 compiler that adds code to correct previously ill-typed computations that arise from the use of covariant specialization. The modification we propose does not affect the semantics of those computations without type errors. Furthermore, the new semantics of the previously ill-typed computations is defined in a very ``natural'' way and ensures the type safety (w.r.t. covariance) of the program. Since the solution consists of a conservative backward-compatible modification of the compiler, it does not require, unlike other solutions, any modification of existing O2 code. Our solution is based solely on a type-theoretic analysis and thus is general. Therefore, although this paper applies it to a particular programming language, the same ideas could easily be applied to other languages that use covariant specialization.

BibTeX Style Reference

@techreport(boyland/castagna:95covariance,
  author =      {John Boyland and Giuseppe Castagna},
  title =       {Type-Safe Compilation of Covariant
                 Specialization: A Practical Case},
  institution = {University of California, Berkeley},
  number = 	{CSD-95-890},
  month =       nov,
  year =        1995)

@inproceedings(boyland/castagna:96covariance,
  author =      {John Boyland and Giuseppe Castagna},
  title =       {Type-Safe Compilation of Covariant
                 Specialization: A Practical Case},
  booktitle = 	{ECOOP '96 --- Object-Oriented Programming},
  series = 	{Lecture Notes in Computer Science},
  volume = 	1098,
  publisher =   {Springer Verlag},
  address =     {Berlin},
  year =        1996,
  pages = 	{3-25})

How to Get a Copy

The technical report is available electronically. The proceedings volume can be purchased from Springer Verlag. Reprints for academic use are available electronically by permission of Springer.


Last Modified: March 30, 1998

Type-Safe Compilation of Covariant Specialization / boyland@cs.uwm.edu