Union Types for Object-Oriented Programming.

Atsushi Igarashi, Hideshi Nagira · The Journal of Object Technology · 2007

We propose union types for statically typed class-based object-oriented languages as a means to enhance the flexibility of subtyping.As its name suggests, a union type can be considered the set union of instances of several types and behaves as their least common supertype.It also plays the role of an interface that "factors out" commonality-fields of the same name and methods with similar signatures-of given types.Union types can be useful for implementing heterogeneous collections and for grouping independently developed classes with similar interfaces, which has been considered difficult in languages like Java.To rigorously show the safety of union types, we formalize them on top of Featherweight Java and prove that the type system is sound.1 A notable exception is wildcards [16] in Java 5.0.

Read the paper · More papers on PaperTik