Check for avoiding invalidating old dependencies on upgrades

Check for avoiding invalidating old dependencies on upgrades

Hello.

I'd like to receive some comments about my patch to #170825 and
possibly have it merged. Currently a package upgrade can invalidate a
dependency satisfied by the old version of the package but not the new
one. I've added a check to catch this situation.