more efficient codegen for typeassert