Fix the COERCE transform for complexes.

It got some corner cases wrong. Based on the patch by Jan Moringen.