skip to main content
10.1145/1167473.1167498acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

A flow-based approach for variant parametric types

Published:16 October 2006Publication History

ABSTRACT

A promising approach for type-safe generic codes in the object-oriented paradigm is variant parametric type, which allows covariant and contravariant subtyping on fields where appropriate. Previous approaches formalise variant type as a special case of the existential type system. In this paper, we present a new framework based on flow analysis and modular type checking to provide a simple but accurate model for capturing generic types. Our scheme stands to benefit from past (and future) advances in flow analysis and subtyping constraints. Furthermore, it fully supports casting for variant types with a special reflection mechanism, called cast capture, to handle objects with unknown types. We have built a constraint-based type checker and have proven its soundness. We have also successfully annotated a suite of Java libraries and client code with our flow-based variant type system.

References

  1. Ole Agesen. The cartesian product algorithm: Simple and precise type inference of parametric polymorphism. In ECOOP '95: Proceedings of the 9th European Conference on Object-Oriented Programming, pages 2-26, London, UK, 1995. Springer-Verlag.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. IC-Parc at Imperial College. ECLiPSe Constraint Logic Programming. http://www.icparc.ic.ac.uk/eclipse/.]]Google ScholarGoogle Scholar
  3. Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: adding genericity to the Java programming language. In OOPSLA '98: Proceedings of the 13th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 183--200, New York, NY, USA, 1998. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Martin Buchi and Wolfgang Weck. Compound types for Java. In OOPSLA '98: Proceedings of the 13th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 362--373, New York, NY, USA, 1998. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Peter S. Canning, William R. Cook,Walter L. Hill, Walter G. Olthoff, and John C. Mitchell. F-Bounded polymorphism for object-oriented programming. In Conference on Functional Programming Languages and Computer Architecture, pages 273--280, 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Luca Cardelli. Notes about Fω<:. 1994. Available at http://research.microsoft.com/Users/luca/Notes/FwSub.ps.]]Google ScholarGoogle Scholar
  7. Luca Cardelli and Peter Wegner. On understanding types, data abstraction, and polymorphism. ACM Comput. Surv., 17(4):471--522, 1985.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N.Wegman, and F. Kenneth Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Trans. Program. Lang. Syst., 13(4):451--490, 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Adriana Compagnoni Dominic Duggan. Subtyping for object type constructors. In Foundations of Object-Oriented Languages (FOOL 1999), 1999.]]Google ScholarGoogle Scholar
  10. Alan Donovan, Adam Kiezun, Matthew S. Tschantz, and Michael D. Ernst. Converting Java programs to use generic libraries. In OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 15--34, New York, NY, USA, 2004. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Dominic Duggan. Modular type-based reverse engineering of parameterized types in Java code. In Proceedings of the 1999 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA '99), pages 97--113, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Burak Emir, Andrew J. Kennedy, Claudio Russo, and Dachuan Yu. Variance and generalized constraints for C# generics. In Proceedings of the 20th European Conference on Object-Oriented Programming (ECOOP), July 2006.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Thom Fruhwirth and et al. Constraint Handling Rules. http://www.cs.kuleuven.ac.be/~dtai/projects/CHR/.]]Google ScholarGoogle Scholar
  14. Robert Fuhrer, Frank Tip, Adam Kiezun, Julian Dolby, and Markus Keller. Efficiently refactoring Java applications to use generic libraries. In ECOOP '05: Proceedings of the 19th European Conference on Object-Oriented Programming, July 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Fritz Henglein and Jakob Rehof. The complexity of subtype entailment for simple types. In Proceedings of 12th Symposium on Logic in Computer Science (LICS '97), pages 352--361, June 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Fritz Henglein and Jakob Rehof. Constraint automata and the complexity of recursive subtype entailment for simple type. In Automata, Languages and Programming, 25th International Colloquium, ICALP'98, pages 616--627, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Atsushi Igarashi and Mirko Viroli. On variance-based subtyping for parametric types. In ECOOP '02: Proceedings of the 16th European Conference on Object-Oriented Programming, pages 441--469, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Atsushi Igarashi and Mirko Viroli. Variant parametric types: A flexible subtyping scheme for generics. ACM Trans. Program. Lang. Syst., 2006.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Andrew Kennedy and Don Syme. Design and implementation of generics for the .NET common language runtime. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 1--12, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Karl Mazurak and Steve Zdancewic. Type inference for Java 5: Wildcards, F-Bounds, and Undecidability. 2006. A note available at http://www.cis.upenn.edu/~stevez/note.html.]]Google ScholarGoogle Scholar
  21. John C. Mitchell and Gordon D. Plotkin. Abstract types have existential type. ACM Trans. Program. Lang. Syst., 10(3):470--502, 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Bengt Nordstrom, Kent Petersson, and Jan M. Smith. Programming in Martin-Lof's Type Theory. Oxford University Press, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Martin Odersky, Christoph Zenger, and Matthias Zenger. Colored local type inference. In The 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 41--53, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Martin Odersky and Matthias Zenger. Scalable component abstractions. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2005, pages 41--57, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Jens Palsberg and Patrick O'Keefe. A type system equivalent to flow analysis. In 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 367--378, 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Jens Palsberg and Christina Pavlopoulou. From polyvariant flow information to intersection and union types. In The 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 197--208, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Simon Peyton-Jones and et al. Glasgow Haskell Compiler. http://www.haskell.org/ghc.]]Google ScholarGoogle Scholar
  28. Benjamin C. Pierce. Bounded quantification is undecidable. Information and Computation, 112(1):131--165, July 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Benjamin C. Pierce. Types and Programming Languages. The MIT Press, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Benjamin C. Pierce and David N. Turner. Local type inference. In Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 252--265, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. John Plevyak and Andrew A. Chien. Precise concrete type inference for object-oriented languages. In OOPSLA, pages 324--340, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. François Pottier. Simplifying subtyping constraints. In Proceedings of the 1996 ACM SIGPLAN International Conference on Functional Programming (ICFP '96), pages 122--133, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Martin Steffen. Polarized Higher-Order Subtyping. PhD thesis, Universitat Erlangen-Nurnberg, 1997.]]Google ScholarGoogle Scholar
  34. Zhendong Su, Alexander Aiken, Joachim Niehren, Tim Priesnitz, and Ralf Treinen. The first-order theory of subtyping constraints. In The 29th SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 203--216, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Kresten Krab Thorup and Mads Torgersen. Unifying genericity - combining the benefits of virtual types and parameterized classes. In ECOOP'99 - Object-Oriented Programming, 13th European Conference, pages 186--204, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Mads Torgersen, Erik Ernst, and Christian Plesner Hansen. Wild FJ. In Foundations of Object-Oriented Languages (FOOL 2005), Long Beach, CA, January 2005.]]Google ScholarGoogle Scholar
  37. Mads Torgersen, Erik Ernst, Christian Plesner Hansen, Peter von der Ahé, Gilad Bracha, and Neal M. Gafter. Adding Wildcards to the Java programming language. Journal of Object Technology, 3(11):97--116, 2004.]]Google ScholarGoogle ScholarCross RefCross Ref
  38. Valery Trifonov and Scott F. Smith. Subtyping constrained types. In Static Analysis, Third International Symposium, SAS'96, pages 349--365, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Mirko Viroli and Antonio Natali. Parametric polymorphism in java: an approach to translation based on reflective features. In Proceedings of the 2000 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA 2000), pages 146--165, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Daniel von Dincklage and Amer Diwan. Converting Java classes to use generics. In Proceedings of the 19th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 1--14, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Tiejun Wang and Scott F. Smith. Precise constraint-based type inference for java. In ECOOP '01: Proceedings of the 15th European Conference on Object-Oriented Programming, pages 99--117, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A flow-based approach for variant parametric types

                  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

                  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!