Mutate generic catch block type when needed. Fixes #12799