Proceedings Article10.1142/9789812770998_0014
Type inference for polymorphic methods in Java-like languages.
Davide Ancona,Giovanni Lagorio,Elena Zucca +2 more
- 01 Sep 2007
pp 118-129
12
TL;DR: This work defines a type system with polymorphic types for methods and automatically infer these types when type annotations are omitted, and describes an algorithm for type inference and proves its soundness and completeness.
read more
Abstract: In mainstream class-based object-oriented languages with nominal types, like C++, Java and C#, typechecking algorithms require methods to be annotated with their parameter types, which are either fixed or constrained by a (nominal) bound. On the contrary, languages like ML, CaML and Haskell use powerful type inference algorithms capable of calculating the type for a function in which parameter types are left unspecified. This inferred type is possibly polymorphic, hence functions can be applied to arguments of different, unrelated, types, which are instances of the same schema. We show that, surprisingly enough, the latter scenario works smoothly for Java-like languages too. That is, we can define polymorphic types for methods and automatically infer these types when type annotations are omitted. These polymorphic types intuitively capture the (less restrictive) requirements on arguments needed to safely apply the method. Moreover, the approach enjoys separate compilation a la Java. We formalize our ideas on a minimal Java subset, for which we define a type system with polymorphic types and prove its soundness. We then describe an algorithm for type inference and prove its soundness and completeness. A prototype implementing inference of polymorphic types from untyped code is available.
read more
Chat with Paper
AI Agents for this Paper
Find similar papers on Google Scholar, PubMed and Arxiv
Write a critical review of this paper
Analyze citations of this paper to find unaddressed research gaps
Citations
Integrating typed and untyped code in a scripting language
Tobias Wrigstad,Francesco Zappa Nardelli,Sylvain Lebresne,Johan Östlund,Jan Vitek +4 more
- 17 Jan 2010
TL;DR: Like types are introduced, a novel intermediate point between dynamic and static typing, which provides some of the benefits of static typing without decreasing the expressiveness of the language.
115
Coinductive Type Systems for Object-Oriented Languages
Davide Ancona,Giovanni Lagorio +1 more
- 30 Jul 2009
TL;DR: A novel approach based on coinductive logic to specify type systems of programming languages, which involves infinite terms and proof trees not representable in a finite way, thus providing a theoretical limit to type inference of object-oriented programs.
41
Idealized coinductive type systems for imperative object-oriented programs
Davide Ancona,Giovanni Lagorio +1 more
TL;DR: This paper investigates how a novel approach to define idealized type systems for object-oriented languages, based on compilation of programs into Horn formulas which are interpreted w.r.t. the coinductive Herbrand model, can be applied also in the presence of imperative features.
•Proceedings Article
An idealized coinductive type system for imperative object-oriented programs.
Davide Ancona,Giovanni Lagorio +1 more
- 01 Jan 2009
TL;DR: In this article, a natural translation of Static Single Assignment intermediate form programs into Horn formulas, where ϕ functions correspond to union types, is proposed, and applied to the case of imperative features.
20
Type Inference by Coinductive Logic Programming
Davide Ancona,Giovanni Lagorio,Elena Zucca +2 more
- 07 Jun 2009
TL;DR: A novel approach to constraint-based type inference based on coinductive logic that obtains a very precise type inference and provides new insights into the challenging problem of type inference for object-oriented programs.
References
A theory of type polymorphism in programming
TL;DR: This work presents a formal type discipline for polymorphic procedures in the context of a simple programming language, and a compile time type-checking algorithm w which enforces the discipline.
2.6K
Featherweight Java: a minimal core calculus for Java and GJ
TL;DR: This work extends Featherweight Java with generic classes in the style of GJ and gives a detailed proof of type safety, which formalizes for the first time some of the key features ofGJ.
Parameterized types for Java
Joseph A. Bank,Andrew C. Myers,Barbara Liskov +2 more
- 01 Jan 1997
TL;DR: The rationale for the design decisions and the impact of the extension on other parts of Java, including arrays and the class library are discussed, and optional extensions to the Java virtual machine to allow parameterized bytecodes are described, and how to verify them efficiently.
The Cartesian Product Algorithm
Ole Agesen
- 07 Aug 1995
TL;DR: In this paper, the focus of this paper is on type inference for object-oriented type systems, where concrete types are used to support compilation, application delivery, and debugging in OO environments.
234
The Essence of Principal Typings
Joseph Brian Wells
- 08 Jul 2002
TL;DR: A new general definition of principal typings which does not depend on the details of any particular type system is presented and is used to prove that certain polymorphic type systems using ?