introduces failsafe against endless type printing

The parent commit works around a particular problem that led to a compiler
freeze in SI-8158, whereas this commit introduces a general solution -
a cache that tracks all types that we've recursed into during printing.

I can't immediately come up with an example of a type that would be caught
by this safety net, but unknown unknowns are the worst of them all, so why not
guard against them while we can.