integrate subtyping and safe upcasts