That's what a typechecker gives you–an automated enforcement mechanism for ruling out certain errors during refactoring.