anchor.diff:        }
       }
   
  -    // The following map contains for every declaration the set of the
  -    // declarations it references.
  -    var dependencies = {
  -      for (var declaration in topDeclarations)
  -        declaration: declaration
  -            .traverseNodesInDFS()
  -            .expand((e) => [
  -                  if (e is SimpleIdentifier) e.staticElement,
  -                  // with `id++` staticElement of `id` is null
  -                  if (e is CompoundAssignmentExpression) ...[
  -                    e.readElement,
  -                    e.writeElement,
  -                  ],
  -                ])
  -            .whereNotNull()
  -            .map((e) => e.thisOrAncestorMatching((a) =>
  -                a.enclosingElement3 == null ||
  -                a.enclosingElement3 is CompilationUnitElement))
  -            .map((e) => declarationByElement[e])
  -            .whereNotNull()
  -            .where((e) => e != declaration)
  -            .toSet(),
  -    };
  +    // The set of the declarations which each top-level declaration references.
  +    var dependencies = <Declaration, Set<Declaration>>{};
  +    for (var declaration in topDeclarations) {
  +      var visitor = _IdentifierVisitor(declarationByElement);
  +      declaration.accept(visitor);
  +      dependencies[declaration] = visitor.declarations;
  +    }
   
       var usedMembers = entryPoints.toSet();
       // The following variable will be used to visit every reachable declaration
  
positive.code:     // element is marked as used and we add its dependencies in the declaration
      // list to traverse. Once this list is empty `usedMembers` contains every
      // declarations reachable from an entry-point.
      var toTraverse = Queue.of(usedMembers);
      while (toTraverse.isNotEmpty) {
        var declaration = toTraverse.removeLast();
        for (var dep in dependencies[declaration]!) {
          if (usedMembers.add(dep)) {
            toTraverse.add(dep);
          }
        }
      }
  
negative.code: import 'package:analyzer/dart/ast/visitor.dart';
  import 'package:analyzer/dart/element/element.dart';
  import 'package:analyzer/dart/element/type.dart';
  
  import '../analyzer.dart';
  
  const _desc = 'Unreachable top-level members in executable libraries.';
  
  