skip to main content
research-article

Semantic subtyping for imperative object-oriented languages

Published:19 October 2016Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

References

  1. M. Abadi and L. Cardelli. A Theory of Objects. Monographs in Computer Science. Springer, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. P. Aczel. An introduction to inductive definitions. In J. Barwise, editor, Handbook of Mathematical logic. North Holland, 1977.Google ScholarGoogle Scholar
  3. J. Altidor, C. Reichenbach, and Y. Smaragdakis. Java wildcards meet definition-site variance. In ECOOP’12, pages 509–534, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. Anderson, P. Giannini, and S. Drossopoulou. Towards type inference for javascript. In ECOOP 2005, pages 428–452, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarCross RefCross Ref
  10. N. Cameron, S. Drossopoulou, and E. Ernst. A model for Java with wildcards. In ECOOP 2008, pages 2–26, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. G. Castagna, T. Petrucciani, and K. Nguyen. Set-theoretic types for polymorphic variants. In ICFP 2016, 2016. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. B. Courcelle. Fundamental properties of infinite trees. Theoretical Computer Science, 25:95–169, 1983.Google ScholarGoogle Scholar
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. Gil and I. Maman. Whiteoak: Introducing structural typing into Java. In OOPSLA ’08, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. B. Hackett and S. Guo. Fast and precise hybrid type inference for javascript. In PLDI ’12, pages 239–250, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. P. Heidegger and P. Thiemann. Recency types for analyzing scripting languages. In ECOOP 2010, pages 200–224, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. H. Hosoya and B. C. Pierce. XDuce: A statically typed XML processing language. ACM Trans. Internet Techn., 3(2):117– 148, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. Igarashi and H. Nagira. Union types for object-oriented programming. Journ. of Object Technology, 6(2):47–68, 2007.Google ScholarGoogle ScholarCross RefCross Ref
  23. T. Jones, M. Homer, and J. Noble. Brand Objects for Nominal Typing. In ECOOP 2015, pages 198–221, 2015.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. B. Lerner, J. Politz, A. Guha, and S. Krishnamurthi. Tejas: retrofitting type systems for javascript. In DLS’13, pages 1–16, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. X. Leroy and H. Grall. Coinductive big-step operational semantics. Information and Computation, 207:284–304, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. D. Malayeri and J. Aldrich. Integrating nominal and structural subtyping. In ECOOP 2008, pages 260–284, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarCross RefCross Ref
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Semantic subtyping for imperative object-oriented languages

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 51, Issue 10
            OOPSLA '16
            October 2016
            915 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/3022671
            Issue’s Table of Contents
            • cover image ACM Conferences
              OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
              October 2016
              915 pages
              ISBN:9781450344449
              DOI:10.1145/2983990

            Copyright © 2016 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 19 October 2016

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!