Avoid modifying the AST as a side effect of type checking.

This never felt like a great idea, but I finally came across some cases
where it causes actual problems, so it has to go.