Version 2.18.0-251.0.dev

Merge commit 'ecba15b64164d271dbb0734c19610faf645f866c' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index fdf5ba2..0ef2a0e 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -46,7 +46,7 @@
   final SummaryDataStore store = SummaryDataStore();
 
   late final AnalysisContextImpl analysisContext;
-  late LinkedElementFactory elementFactory;
+  late final LinkedElementFactory elementFactory;
 
   Set<LibraryCycle> loadedBundles = Set.identity();
 
@@ -120,6 +120,7 @@
     required LibraryFileStateKind targetLibrary,
     required OperationPerformanceImpl performance,
   }) async {
+    addToLogRing('[load][targetLibrary: ${targetLibrary.file}]');
     var librariesTotal = 0;
     var librariesLoaded = 0;
     var librariesLinked = 0;
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index 27c1357..45859a4 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -2,6 +2,8 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'dart:collection';
+
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/src/context/context.dart';
 import 'package:analyzer/src/dart/analysis/session.dart';
@@ -13,6 +15,15 @@
 import 'package:analyzer/src/summary2/reference.dart';
 import 'package:meta/meta.dart';
 
+final _logRing = Queue<String>();
+
+void addToLogRing(String entry) {
+  _logRing.add(entry);
+  if (_logRing.length > 10) {
+    _logRing.removeFirst();
+  }
+}
+
 class LinkedElementFactory {
   static final _dartCoreUri = Uri.parse('dart:core');
   static final _dartAsyncUri = Uri.parse('dart:async');
@@ -104,9 +115,10 @@
       final rootChildren = rootReference.children.map((e) => e.name).toList();
       throw ArgumentError(
         'Missing library: $uri\n'
-        'Libraries: $uriListWithLibraryElements'
-        'Root children: $rootChildren'
-        'Readers: ${_libraryReaders.keys.toList()}',
+        'Libraries: $uriListWithLibraryElements\n'
+        'Root children: $rootChildren\n'
+        'Readers: ${_libraryReaders.keys.toList()}\n'
+        'Log: ${_logRing.join('\n')}\n',
       );
     }
 
@@ -217,6 +229,7 @@
   /// Remove libraries with the specified URIs from the reference tree, and
   /// any session level caches.
   void removeLibraries(Set<Uri> uriSet) {
+    addToLogRing('[removeLibraries][uriSet: $uriSet][${StackTrace.current}]');
     for (final uri in uriSet) {
       _libraryReaders.remove(uri);
       final libraryReference = rootReference.removeChild('$uri');
diff --git a/tools/VERSION b/tools/VERSION
index e441767..d2b76b1 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 18
 PATCH 0
-PRERELEASE 250
+PRERELEASE 251
 PRERELEASE_PATCH 0
\ No newline at end of file