Fix checking cast type.