anchor.diff:            // shouldn't confuse by also reporting an unused prefix.
             _unusedImports.remove(importDirective);
           }
  +        var namespace = _computeNamespace(importDirective);
  +        if (namespace == null) {
  +          continue;
  +        }
           for (var element in elements) {
  -          if (namespace?.getPrefixed(prefix.name, element.name!) != null) {
  +          if (namespace.getPrefixed(prefix.name, element.name!) != null) {
               _unusedImports.remove(importDirective);
               _removeFromUnusedShownNamesMap(element, importDirective);
             }
           }
         }
  -    });
  +    }
  +
       // Process top-level elements.
       for (Element element in usedElements.elements) {
         if (everythingIsKnownToBeUsed()) {
  
positive.code:         _unusedImports.isEmpty && _unusedShownNamesMap.isEmpty;
  
      // Process import prefixes.
      usedElements.prefixMap
          .forEach((PrefixElement prefix, List<Element> elements) {
        if (everythingIsKnownToBeUsed()) {
          return;
        }
        // Find import directives using namespaces.
        for (var importDirective
            in _prefixElementMap[prefix] ?? <ImportDirective>[]) {
          var namespace = _computeNamespace(importDirective);
          if (elements.isEmpty) {
            // [prefix] and [elements] were added to [usedElements.prefixMap] but
            // [elements] is empty, so the prefix was referenced incorrectly.
  
negative.code:           // An extension might be used solely because one or more instance
            // members are referenced, which does not require explicit use of the
            // prefix. We still indicate that the import directive is used.
            if (namespace.getPrefixed(prefix, elementName) == extensionElement) {
              _unusedImports.remove(importDirective);
              _removeFromUnusedShownNamesMap(extensionElement, importDirective);
            }
  