The code currently attempting to recursively find uses of a deprecated def has a few deficiences:
- It recurses into all def uses. This is problematic as it also causes any users of a def using a deprecated def, to be considered deprecated, causing a transitive chain of deprecated defs (see H_ButNotTransitivelyInNonAnonymousDef in test case for reproducer)
- It did not recurse into other kinds of fields, such as list and DAGs
This patch fixes the issue by reworking the code to properly recurse into inits and not to recurse into def uses unless they are anonymous defs. Since inits (including DAG, List and anonymous defs) are uniqued, the memoization is kept and remains profitable.
This is cheaper than the lookup, could we do this first?