It didn't figure them out at all, the programmer had to figure them out the hard way and then code them in so that the compiler understands them.
GC is figuring out things mostly correctly and the programmer can focus on other things, at least until they hit a performance problem :)