Java wildcards meet definition-site variance

  • Authors:
  • John Altidor;Christoph Reichenbach;Yannis Smaragdakis

  • Affiliations:
  • University of Massachusetts, Amherst;University of Massachusetts, Amherst;University of Massachusetts, Amherst, USA,University of Athens, Greece

  • Venue:
  • ECOOP'12 Proceedings of the 26th European conference on Object-Oriented Programming
  • Year:
  • 2012

Quantified Score

Hi-index 0.00

Visualization

Abstract

Variance is concerned with the interplay of parametric polymorphism (i.e., templates, generics) and subtyping. The study of variance gives answers to the question of when an instantiation of a generic class can be a subtype of another. In this work, we combine the mechanisms of use-site variance (as in Java) and definition-site variance (as in Scala and C#) in a single type system, based on Java. This allows maximum flexibility in both the specification and use of generic types, thus increasing the reusability of code. Our VarJ calculus achieves a safe synergy of def-site and use-site variance, while supporting the full complexities of the Java realization of variance, including F-bounded polymorphism and wildcard capture. We show that the interaction of these features with definition-site variance is non-trivial and offer a full proof of soundness--the first in the literature for an approach combining variance mechanisms.