anchor.diff:      var library = modelBuilder.fromElement(element!.library!) as Library?;
       if (library == null) {
         warn(PackageWarning.noDefiningLibraryFound);
  -    }
  -    Library? fallback;
  +    } else {
  +      return library;
  +    }
       if (enclosingElement is ModelElement) {
  -      fallback = (enclosingElement as ModelElement).definingLibrary;
  -    }
  -    return library ?? fallback ?? this.library!;
  -  }
  -
  -  Library? _canonicalLibrary;
  -
  -  // [_canonicalLibrary] can be null so we can't check against null to see
  -  // whether we tried to compute it before.
  -  bool _canonicalLibraryIsSet = false;
  -
  -  @override
  -  Library? get canonicalLibrary {
  -    if (!_canonicalLibraryIsSet) {
  -      // This is not accurate if we are constructing the Package.
  -      assert(packageGraph.allLibrariesAdded);
  -
  -      // Privately named elements can never have a canonical library, so
  -      // just shortcut them out.
  -      if (!utils.hasPublicName(element!)) {
  -        _canonicalLibrary = null;
  -      } else if (!packageGraph.localPublicLibraries.contains(definingLibrary)) {
  -        _canonicalLibrary = _searchForCanonicalLibrary();
  -      } else {
  -        _canonicalLibrary = definingLibrary;
  -      }
  -      // Only pretend when not linking to remote packages.
  -      if (this is Inheritable && !config.linkToRemote) {
  -        if ((this as Inheritable).isInherited &&
  -            _canonicalLibrary == null &&
  -            packageGraph.publicLibraries.contains(library)) {
  -          // In the event we've inherited a field from an object that isn't
  -          // directly reexported, we may need to pretend we are canonical for
  -          // this.
  -          _canonicalLibrary = library;
  -        }
  -      }
  -      _canonicalLibraryIsSet = true;
  -    }
  -    assert(_canonicalLibrary == null ||
  -        packageGraph.publicLibraries.contains(_canonicalLibrary));
  -    return _canonicalLibrary;
  -  }
  +      return (enclosingElement as ModelElement).definingLibrary;
  +    } else {
  +      return this.library!;
  +    }
  +  }
  +
  +  @override
  +  late final Library? canonicalLibrary = () {
  +    // This is not accurate if we are constructing the Package.
  +    assert(packageGraph.allLibrariesAdded);
  +    Library? canonicalLibraryPossibility;
  +
  +    // Privately named elements can never have a canonical library, so
  +    // just shortcut them out.
  +    if (!utils.hasPublicName(element!)) {
  +      canonicalLibraryPossibility = null;
  +    } else if (!packageGraph.localPublicLibraries.contains(definingLibrary)) {
  +      canonicalLibraryPossibility = _searchForCanonicalLibrary();
  +    } else {
  +      canonicalLibraryPossibility = definingLibrary;
  +    }
  +    // Only pretend when not linking to remote packages.
  +    if (this is Inheritable && !config.linkToRemote) {
  +      if ((this as Inheritable).isInherited &&
  +          canonicalLibraryPossibility == null &&
  +          packageGraph.publicLibraries.contains(library)) {
  +        // In the event we've inherited a field from an object that isn't
  +        // directly reexported, we may need to pretend we are canonical for
  +        // this.
  +        canonicalLibraryPossibility = library;
  +      }
  +    }
  +    assert(canonicalLibraryPossibility == null ||
  +        packageGraph.publicLibraries.contains(canonicalLibraryPossibility));
  +    return canonicalLibraryPossibility;
  +  }();
   
     Library? _searchForCanonicalLibrary() {
       var thisAndExported = definingLibrary.exportedInLibraries;
  
positive.code:   /// that need to be documented.  See [Feature] for a list.
    Set<Feature> get features {
      return {
        ...annotations.where((a) => !_specialFeatures.contains(a.name)),
        // 'const' and 'static' are not needed here because 'const' and 'static'
        // elements get their own sections in the doc.
        if (isFinal) Feature.finalFeature,
  
negative.code:   @override
    bool get hasDocumentationComment => element!.documentationComment != null;
  
    @override
    late final String sourceCode =
        _sourceCodeRenderer.renderSourceCode(super.sourceCode);
  
    @override
    int compareTo(dynamic other) {
  