Abstract
Semantic subtyping is an approach for defining sound and complete procedures to decide subtyping for expressive types, including union and intersection types; although it has been exploited especially in functional languages for XML based programming, recently it has been partially investigated in the context of object-oriented languages, and a sound and complete subtyping algorithm has been proposed for record types, but restricted to immutable fields, with union and recursive types interpreted coinductively to support cyclic objects. In this work we address the problem of studying semantic subtyping for imperative object-oriented languages, where fields can be mutable; in particular, we add read/write field annotations to record types, and, besides union, we consider intersection types as well, while maintaining coinductive interpretation of recursive types. In this way, we get a richer notion of type with a flexible subtyping relation, able to express a variety of type invariants useful for enforcing static guarantees for mutable objects. The addition of these features radically changes the defi- nition of subtyping, and, hence, the corresponding decision procedure, and surprisingly invalidates some subtyping laws that hold in the functional setting. We propose an intuitive model where mutable record val- ues contain type information to specify the values that can be correctly stored in fields. Such a model, and the correspond- ing subtyping rules, require particular care to avoid circularity between coinductive judgments and their negations which, by duality, have to be interpreted inductively. A sound and complete subtyping algorithm is provided, together with a prototype implementation.
Supplemental Material
Available for Download
The archive contains a directory with the Prolog implementation of the subtyping algorithm and the image of a virtual machine that can be used to run it.
- M. Abadi and L. Cardelli. A Theory of Objects. Monographs in Computer Science. Springer, 1996. Google Scholar
Digital Library
- P. Aczel. An introduction to inductive definitions. In J. Barwise, editor, Handbook of Mathematical logic. North Holland, 1977.Google Scholar
- J. Altidor, C. Reichenbach, and Y. Smaragdakis. Java wildcards meet definition-site variance. In ECOOP’12, pages 509–534, 2012. Google Scholar
Digital Library
- D. Ancona and A. Corradi. Sound and complete subtyping between coinductive types for object-oriented languages. In ECOOP 2014 - Object-Oriented Programming - 28th European Conference, volume 8586 of Lecture Notes in Computer Science, pages 282–307. Springer, 2014. Google Scholar
Digital Library
- D. Ancona and A. Corradi. Semantic subtyping between coinductive mutable record types with unions and intersections. In Italian Conference on Theoretical Computer Science (ICTCS 2015), 2015. On-line proceedings.Google Scholar
- D. Ancona and G. Lagorio. Coinductive type systems for object-oriented languages. In S. Drossopoulou, editor, ECOOP 2009 - Object-Oriented Programming, volume 5653 of LNCS, pages 2–26. Springer, 2009. ISBN 978-3-642-03012-3. Google Scholar
Digital Library
- C. Anderson, P. Giannini, and S. Drossopoulou. Towards type inference for javascript. In ECOOP 2005, pages 428–452, 2005. Google Scholar
Digital Library
- F. Barbanera, M. Dezani-Ciancaglini, and U. De’Liguoro. Intersection and union types: Syntax and semantics. Information and Computation, 119(2):202–230, 1995. Google Scholar
Digital Library
- M. Bonsangue, J. Rot, D. Ancona, F. de Boer, and J. Rutten. A coalgebraic foundation for coinductive union types. In ICALP 2014 - 41st International Colloquium on Automata, Languages and Programming, pages 62–73, 2014.Google Scholar
Cross Ref
- N. Cameron, S. Drossopoulou, and E. Ernst. A model for Java with wildcards. In ECOOP 2008, pages 2–26, 2008. Google Scholar
Digital Library
- G. Castagna, R. De Nicola, and D. Varacca. Semantic subtyping for the π-calculus. Theoretical Computer Science, 398 (1-3):217–242, 2008. doi: 10.1016/j.tcs.2008.01.049. Google Scholar
Digital Library
- G. Castagna, K. Nguyen, Z. Xu, H. Im, S. Lenglet, and L. Padovani. Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation. In POPL ’14, pages 5–18, 2014. Google Scholar
Digital Library
- G. Castagna, K. Nguyen, Z. Xu, and P. Abate. Polymorphic functions with set-theoretic types: Part 2: Local type inference and type reconstruction. In POPL 2015, pages 289–302, 2015. Google Scholar
Digital Library
- G. Castagna, T. Petrucciani, and K. Nguyen. Set-theoretic types for polymorphic variants. In ICFP 2016, 2016. To appear. Google Scholar
Digital Library
- B. Courcelle. Fundamental properties of infinite trees. Theoretical Computer Science, 25:95–169, 1983.Google Scholar
- M. Fähndrich and K. R. M. Leino. Declaring and checking non-null types in an object-oriented language. In OOPSLA 2003, pages 302–312, 2003. Google Scholar
Digital Library
- A. Frisch, G. Castagna, and V. Benzaken. Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM, 55(4), 2008. Google Scholar
Digital Library
- J. Gil and I. Maman. Whiteoak: Introducing structural typing into Java. In OOPSLA ’08, 2008. Google Scholar
Digital Library
- B. Hackett and S. Guo. Fast and precise hybrid type inference for javascript. In PLDI ’12, pages 239–250, 2012. Google Scholar
Digital Library
- P. Heidegger and P. Thiemann. Recency types for analyzing scripting languages. In ECOOP 2010, pages 200–224, 2010. Google Scholar
Digital Library
- H. Hosoya and B. C. Pierce. XDuce: A statically typed XML processing language. ACM Trans. Internet Techn., 3(2):117– 148, 2003. Google Scholar
Digital Library
- A. Igarashi and H. Nagira. Union types for object-oriented programming. Journ. of Object Technology, 6(2):47–68, 2007.Google Scholar
Cross Ref
- T. Jones, M. Homer, and J. Noble. Brand Objects for Nominal Typing. In ECOOP 2015, pages 198–221, 2015.Google Scholar
- V. Kashyap, J. Sarracino, J. Wagner, B. Wiedermann, and B. Hardekopf. Type refinement for static analysis of javascript. In DLS’13, pages 17–26, 2013. Google Scholar
Digital Library
- B. Lerner, J. Politz, A. Guha, and S. Krishnamurthi. Tejas: retrofitting type systems for javascript. In DLS’13, pages 1–16, 2013. Google Scholar
Digital Library
- X. Leroy and H. Grall. Coinductive big-step operational semantics. Information and Computation, 207:284–304, 2009. Google Scholar
Digital Library
- D. Malayeri and J. Aldrich. Integrating nominal and structural subtyping. In ECOOP 2008, pages 260–284, 2008. Google Scholar
Digital Library
- L. Simon, A. Bansal, A. Mallya, and G. Gupta. Co-logic programming: Extending logic programming with coinduction. In Automata, Languages and Programming, 34th International Colloquium, ICALP 2007, pages 472–483, 2007. Google Scholar
Digital Library
- M. Torgersen, E. Ernst, C. P. Hansen, P. von der Ahé, G. Bracha, and N. M. Gafter. Adding wildcards to the Java programming language. Journal of Object Technology, 3(11):97–116, 2004.Google Scholar
Cross Ref
- T. Wang and S. F. Smith. Precise constraint-based type inference for Java. In ECOOP’01 - European Conference on Object-Oriented Programming, volume 2072, pages 99–117. Springer, 2001. Google Scholar
Digital Library
Index Terms
Semantic subtyping for imperative object-oriented languages
Recommendations
Semantic subtyping for imperative object-oriented languages
OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and ApplicationsSemantic subtyping is an approach for defining sound and complete procedures to decide subtyping for expressive types, including union and intersection types; although it has been exploited especially in functional languages for XML based programming, ...
Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types
Subtyping relations are usually defined either syntactically by a formal system or semantically by an interpretation of types into an untyped denotational model. This work shows how to define a subtyping relation semantically in the presence of Boolean ...
Complete coinductive subtyping for abstract compilation of object-oriented languages
FTFJP '10: Proceedings of the 12th Workshop on Formal Techniques for Java-Like ProgramsCoinductive abstract compilation is a novel technique, which has been recently introduced, for defining precise type systems for object-oriented languages. In this approach, type inference consists in translating the program to be analyzed into a Horn ...







Comments