Fix `IsValidDependency` for invalid `Dependency` specializations for references (those that decay to invalid specializations for values), so that `IsValidDependency` returns `false` instead of failing to compile.
Fix `IsValidDependency` for invalid `Dependency` specializations for references
(those that decay to invalid specializations for values), so that
`IsValidDependency` returns `false` instead of failing to compile.

This is done by constraining relevant `Dependency` specializations so that they
do not blindly derive from undefined classes, but can be detected to be
themselves undefined.

In general SFINAE works only on the level of declarations. Once an instantiation
is determined to be defined, errors inside it are too late to be detected
gracefully.

PiperOrigin-RevId: 426865796

google/riegeli,google/riegeli,google/riegeli,google/riegeli