Check register classes also when changing them.

We have the same assertion in createVirtualRegister.