Use-site variance approaches such as Java wildcards allows to flexibly derive many co- and contravariant types from one generic class definition. Safety is achieved by restricting the access to members of the parameterized types, but the definition of proper access rules is complicated by the possible nesting of types. Existing approaches for use-site variance relate parameterized classes to bounded existential types and employ a conversion of the type parameters to fresh type variables in order to type an operation. This technique only indirectly explains the operations of a parameterized class and confronts the programmer with type variables which are introduced by the compiler for the purpose of type checking.
In this paper, we propose a more straightforward, uniform and powerful mechanism to systematically address the access restrictions of parameterized types with use-site variance. Parameterized classes receive two type values for each type parameter, and the operations may be determined by simply substituting these values in covariant resp. contravariant positions. The two type values may be interpreted as the bounds of a type range, and we define a safe and flexible variant subtype relation based on range containment. With the exception of wildcard capture, our approach supports all of the common features of other use-site variance models.
Original languageEnglish
Title of host publicationProceedings of the 11th International Workshop on Formal Techniques for Java-like Programs
EditorsAnindya Banerjee
PublisherACM
ISBN (Print)978-1-60558-540-6
Publication statusPublished - 6 Jul 2009
EventFinds and Results from the Swedish Cyprus Expedition: A Gender Perspective at the Medelhavsmuseet - Stockholm, Sweden
Duration: 21 Sep 200925 Sep 2009

Publication series

NameProceedings of the 11th International Workshop on Formal Techniques for Java-like Programs

Conference

ConferenceFinds and Results from the Swedish Cyprus Expedition: A Gender Perspective at the Medelhavsmuseet
CountrySweden
CityStockholm
Period21/09/0925/09/09

    Research areas

  • generic classes, language design, language semantics, subtyping, variance

ID: 1869249