|
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 existential type system where subtyping is undecidable, in general. In this work, 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 cast capture mechanism for objects with unknown type. We have built a constraint-based type checker and have proven its soundness. We have also successfully annotated Java libraries and client codes to be both type-safe and reusable.
|