This is a consequence of the virial theorem of mechanics.

https://en.wikipedia.org/wiki/Virial_theorem

This theorem also lets you conclude that as a nondegenerate star becomes more tightly bound (smaller, for a given mass) it must also become hotter.

(Why did someone downvote this?)

I'll posit it's because the virial theorem is applicable to the time average of a stable system and is therefore a specific case. The time average is not a requirement for this discussion (i.e. dynamics) and invoking that theorem is unnecessary. Ergo it is not a consequence.