An Interval-Based Inference of Variant Parametric Types

Florin Craciun, Wei-Ngan Chin, Guanhua He, Shengchao Qin

    Research output: Chapter in Book/Report/Conference proceedingConference contribution


    Variant parametric types represent the successful integration of subtype and parametric polymorphism to support a more flexible subtyping for Java like languages. A key feature that helps strengthen this integration is the use-site variance. Depending on how the fields are used, each variance denotes a covariant, a contravariant, an invariant or a bivariant subtyping. By annotating variance properties on each type argument to a parametric class, programmers can choose various desirable variance properties for each use of the parametric class. Although Java library classes have been successfully refactored to use variant parametric types, these mechanisms are often criticized, due to the difficulty of choosing appropriate variance annotations. Several algorithms have been proposed for automatically refactoring legacy Java code to use generic libraries, but none can support the full flexibility of the use-site variance-based subtyping. This paper addresses this difficulty by proposing a novel interval-based approach to inferring both the variance annotations and the type arguments. Each variant parametric type is regarded as an interval type with two type bounds, a lower bound for writing and an upper bound for reading. We propose a constraint-based inference algorithm that works on a per method basis, as a summary-based analysis.
    Original languageEnglish
    Title of host publicationProgramming Languages and Systems. ESOP 2009
    EditorsG Castagna
    PublisherSpringer Berlin
    ISBN (Electronic)978-3-642-00590-9
    ISBN (Print)978-3-642-00589-3
    Publication statusPublished - 2009
    EventProgramming Languages and Systems, 18th European Symposium on Programming: Held as part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009 - York, United Kingdom
    Duration: 22 Mar 200929 Mar 2009
    Conference number: 18

    Publication series

    NameLecture Notes in Computer Science
    PublisherSpringer, Berlin


    ConferenceProgramming Languages and Systems, 18th European Symposium on Programming
    Abbreviated titleESOP
    Country/TerritoryUnited Kingdom


    Dive into the research topics of 'An Interval-Based Inference of Variant Parametric Types'. Together they form a unique fingerprint.

    Cite this