Elimination of is/asInstanceOf's based on static information.

To avoid doing a `pretransformExpr` if possible, because it costs more than `transformExpr` due to CPS.