Making Type Inference Practical

We present the implementation of a type inference algorithm for untyped object-oriented programs with inheritance, assignments, and late binding. The algorithm significantly improves our previous one, presented at OOPSLA'91, since it can handle collection classes, such as List, in a useful way. Abo, the complexity has been dramatically improved, from exponential time to low polynomial time. The implementation uses the techniques of incremental graph construction and constraint template instantiation to avoid representing intermediate results, doing superfluous work, and recomputing type information. Experiments indicate that the implementation type checks as much as 100 lines pr. second. This results in a mature product, on which a number of tools can be based, for example a safety tool, an image compression tool, a code optimization tool, and an annotation tool. This may make type inference for object-oriented languages practical.

[1]  Norihisa Suzuki,et al.  Inferring types in Smalltalk , 1981, POPL '81.

[2]  Alan Borning,et al.  A type declaration and inference system for smalltalk , 1982, POPL '82.

[3]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

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

[5]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[6]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[7]  Bent Bruun Kristensen,et al.  The BETA Programming Language , 1987, Research Directions in Object-Oriented Programming.

[8]  Scott Danforth,et al.  Type theories and object-oriented programmimg , 1988, CSUR.

[9]  Uday S. Reddy,et al.  Objects as closures: abstract semantics of object-oriented languages , 1988, LISP and Functional Programming.

[10]  Samuel N. Kamin Inheritance in smalltalk-80: a denotational definition , 1988, POPL '88.

[11]  Jens Palsberg,et al.  A Denotational Semantics af Inheritance and its Correctness , 1989 .

[12]  Justin O. Graver,et al.  Type checking and type inference for object-oriented programming languages , 1989 .

[13]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[14]  Ralph E. Johnson,et al.  A type system for Smalltalk , 1989, POPL '90.

[15]  Jens Palsberg,et al.  A Denotational Semantics of Inheritance and its Correctness , 1989, OOPSLA.

[16]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[17]  William R. Cook,et al.  A denotational semantics of inheritance , 1989 .

[18]  Andreas V. Hense Polymorphic type inference for a simple object oriented programming language with state , 1990 .

[19]  Jens Palsberg,et al.  What is Type-Safe Code Reuse? , 1990, ECOOP.

[20]  Craig Chambers,et al.  Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches , 1991, ECOOP.

[21]  Andreas V. Hense Wrapper Semantics of an Object-Oriented Programming Language with State , 1991, TACS.

[22]  Jens Palsberg,et al.  Object-oriented type inference , 1991, OOPSLA '91.

[23]  Mitchell Wand,et al.  Type inference for record concatenation and multiple inheritance , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[24]  Michael I. Schwartzbach,et al.  Type Inference with Inequalities , 1990, TAPSOFT, Vol.1.

[25]  Jens Palsberg,et al.  Static Typing for Object-Oriented Programming , 1991, Sci. Comput. Program..