Transform useless dynamic cast into static cast