fix bad_cast in WhaleVector

also make use of down_cast method instead of as_type.