Only invalidate package objects that inherit from invalidated files.

Originally described in cf355f18224332c3311b552cd9a777f5624426a4.