Version 2.19.0-25.0.dev

Merge commit '66c4559ff64db1a0b5fc40dc7f2cbf94b13cbd75' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
index 47075ca..5cea4ce 100644
--- a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
@@ -150,6 +150,18 @@
   }
 
   @override
+  void visitAugmentationImportDirective(AugmentationImportDirective node) {
+    final element = node.element;
+    if (element is AugmentationImportElementImpl) {
+      _setOrCreateMetadataElements(element, node.metadata);
+    }
+
+    _withElementWalker(null, () {
+      super.visitAugmentationImportDirective(node);
+    });
+  }
+
+  @override
   void visitBlock(Block node) {
     var outerScope = _nameScope;
     try {
@@ -815,6 +827,18 @@
   }
 
   @override
+  void visitLibraryAugmentationDirective(LibraryAugmentationDirective node) {
+    final element = node.element;
+    if (element is LibraryOrAugmentationElementImpl) {
+      _setOrCreateMetadataElements(element, node.metadata);
+    }
+
+    _withElementWalker(null, () {
+      super.visitLibraryAugmentationDirective(node);
+    });
+  }
+
+  @override
   void visitLibraryDirective(LibraryDirective node) {
     ++_libraryDirectiveIndex;
     var element = node.element;
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
index b484abe..a35c8e2 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
@@ -28,10 +28,8 @@
   @override
   bool get retainDataForTesting => true;
 
-  String get testFilePathPlatform => convertPath(testFilePath);
-
   List<Set<String>> get _linkedCycles {
-    var driver = driverFor(testFilePath);
+    var driver = driverFor(testFile.path);
     return driver.testView!.libraryContext.linkedCycles;
   }
 
@@ -55,7 +53,7 @@
       ),
     );
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 dynamic a = 0;
 int b = a;
 ''');
@@ -84,8 +82,8 @@
 }
 ''');
 
-    var analysisDriver = driverFor(testFilePathPlatform);
-    analysisDriver.changeFile(testFilePathPlatform);
+    var analysisDriver = driverFor(testFile.path);
+    analysisDriver.changeFile(testFile.path);
     await analysisDriver.applyPendingFileChanges();
 
     await resolveTestCode(r'''
@@ -103,8 +101,8 @@
 }
 ''');
 
-    var analysisDriver = driverFor(testFilePathPlatform);
-    analysisDriver.changeFile(testFilePathPlatform);
+    var analysisDriver = driverFor(testFile.path);
+    analysisDriver.changeFile(testFile.path);
     await analysisDriver.applyPendingFileChanges();
 
     await resolveTestCode(r'''
@@ -122,8 +120,8 @@
 }
 ''');
 
-    var analysisDriver = driverFor(testFilePathPlatform);
-    analysisDriver.changeFile(testFilePathPlatform);
+    var analysisDriver = driverFor(testFile.path);
+    analysisDriver.changeFile(testFile.path);
     await analysisDriver.applyPendingFileChanges();
 
     await resolveTestCode(r'''
@@ -137,7 +135,7 @@
   test_change_field_staticFinal_hasConstConstructor_changeInitializer() async {
     useEmptyByteStore();
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 class A {
   static const a = 0;
   static const b = 1;
@@ -150,14 +148,14 @@
     assertType(findElement.field('f').type, 'Set<int>');
 
     // The summary for the library was linked.
-    _assertContainsLinkedCycle({testFilePath}, andClear: true);
+    _assertContainsLinkedCycle({testFile}, andClear: true);
 
     // Dispose the collection, with its driver.
     // The next analysis will recreate it.
     // We will reuse the byte store, so can reuse summaries.
     await disposeAnalysisContextCollection();
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 class A {
   static const a = 0;
   static const b = 1;
@@ -178,7 +176,7 @@
   test_change_functionBody() async {
     useEmptyByteStore();
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 void f() {
   print(0);
 }
@@ -188,14 +186,14 @@
     expect(findNode.integerLiteral('0'), isNotNull);
 
     // The summary for the library was linked.
-    _assertContainsLinkedCycle({testFilePath}, andClear: true);
+    _assertContainsLinkedCycle({testFile}, andClear: true);
 
     // Dispose the collection, with its driver.
     // The next analysis will recreate it.
     // We will reuse the byte store, so can reuse summaries.
     await disposeAnalysisContextCollection();
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 void f() {
   print(1);
 }
@@ -216,7 +214,7 @@
 import 'a.dart';
 ''');
 
-    var driver = driverFor(testFilePath);
+    var driver = driverFor(testFile.path);
 
     // Link both libraries, keep them.
     await driver.getLibraryByUri('package:test/a.dart');
@@ -283,7 +281,7 @@
       ),
     );
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 // ignore:unused_import
 import 'package:aaa/a.dart';
 ''');
@@ -295,7 +293,7 @@
     );
 
     // The summary for the library was linked.
-    _assertContainsLinkedCycle({testFilePath}, andClear: true);
+    _assertContainsLinkedCycle({testFile}, andClear: true);
 
     // We will recreate it with new pubspec.yaml content.
     // But we will reuse the byte store, so can reuse summaries.
@@ -326,7 +324,7 @@
       AnalysisOptionsFileConfig(lints: []),
     );
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 void f() {
   ![0].isEmpty;
 }
@@ -337,7 +335,7 @@
     assertErrorsInResult([]);
 
     // The summary for the library was linked.
-    _assertContainsLinkedCycle({testFilePath}, andClear: true);
+    _assertContainsLinkedCycle({testFile}, andClear: true);
 
     // We will recreate it with new analysis options.
     // But we will reuse the byte store, so can reuse summaries.
@@ -391,8 +389,8 @@
       expect(libraryB.exportNamespace.get('MacroB'), isNull);
     }
 
-    _assertContainsLinkedCycle({a.path});
-    _assertContainsLinkedCycle({b.path}, andClear: true);
+    _assertContainsLinkedCycle({a});
+    _assertContainsLinkedCycle({b}, andClear: true);
 
     // The macro will generate `MacroB`.
     _newFileWithFixedNameMacro('MacroB');
@@ -412,8 +410,8 @@
       expect(libraryB.exportNamespace.get('MacroB'), isNotNull);
     }
 
-    _assertContainsLinkedCycle({a.path});
-    _assertContainsLinkedCycle({b.path}, andClear: true);
+    _assertContainsLinkedCycle({a});
+    _assertContainsLinkedCycle({b}, andClear: true);
   }
 
   test_macro_reanalyze_errors_changeCodeUsedByMacro_importedLibrary() async {
@@ -619,9 +617,9 @@
     ]);
   }
 
-  void _assertContainsLinkedCycle(Set<String> expectedPosix,
+  void _assertContainsLinkedCycle(Set<File> expectedFiles,
       {bool andClear = false}) {
-    var expected = expectedPosix.map(convertPath).toSet();
+    var expected = expectedFiles.map((file) => file.path).toSet();
     expect(_linkedCycles, contains(unorderedEquals(expected)));
     if (andClear) {
       _linkedCycles.clear();
@@ -647,10 +645,9 @@
   /// But this method is used to check returning errors from the cache, or
   /// recomputing when the cache key is expected to be different.
   Future<List<AnalysisError>> _computeTestFileErrors() async {
-    var testFilePathConverted = convertPath(testFilePath);
-    var errorsResult = await contextFor(testFilePathConverted)
+    var errorsResult = await contextFor(testFile.path)
         .currentSession
-        .getErrors(testFilePathConverted) as ErrorsResult;
+        .getErrors(testFile.path) as ErrorsResult;
     return errorsResult.errors;
   }
 
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index e2c62ee..cca27af 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -47,7 +47,7 @@
     // This generated file should be used instead of the writable.
     newFile(generatedPath, '');
 
-    var analysisDriver = driverFor(convertPath(testFilePath));
+    var analysisDriver = driverFor(testFile.path);
 
     var fsState = analysisDriver.fsState;
 
@@ -75,7 +75,7 @@
     // This generated file should be used instead of the writable.
     newFile(generatedPath, '');
 
-    var analysisDriver = driverFor(convertPath(testFilePath));
+    var analysisDriver = driverFor(testFile.path);
 
     var fsState = analysisDriver.fsState;
 
diff --git a/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart b/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
index ac40815..46a5a21 100644
--- a/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
@@ -19,11 +19,9 @@
 @reflectiveTest
 class ResolveForCompletionTest extends PubPackageResolutionTest {
   AnalysisDriver get testDriver {
-    return driverFor(testFilePathPlatform);
+    return driverFor(testFile.path);
   }
 
-  String get testFilePathPlatform => convertPath(testFilePath);
-
   test_class__fieldDeclaration_type_namedType_name() async {
     var result = await _resolveTestCode(r'''
 class A {
@@ -489,10 +487,10 @@
   }
 
   test_processPendingChanges() async {
-    newFile(testFilePath, 'class A {}');
+    addTestFile('class A {}');
 
     // Read the file.
-    testDriver.getFileSync(testFilePathPlatform);
+    testDriver.getFileSync(testFile.path);
 
     // Should call `changeFile()`, and the driver must re-read the file.
     var result = await _resolveTestCode(r'''
@@ -598,7 +596,7 @@
   Future<ResolvedForCompletionResultImpl> _resolveTestCode(
     String content,
   ) async {
-    var path = testFilePathPlatform;
+    var path = testFile.path;
     var offset = _newFileWithOffset(path, content);
 
     testDriver.changeFile(path);
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index c95f1a0..e902f74 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -64,7 +64,7 @@
 
 @reflectiveTest
 class SearchTest extends PubPackageResolutionTest {
-  AnalysisDriver get driver => driverFor(testFilePath);
+  AnalysisDriver get driver => driverFor(testFile.path);
 
   CompilationUnitElement get resultUnitElement => result.unit.declaredElement!;
 
@@ -1118,7 +1118,7 @@
         ..add(name: 'aaa', rootPath: aaaPackageRootPath),
     );
 
-    pathForContextSelection = testFilePath;
+    pathForContextSelection = testFile.path;
 
     await resolveFileCode(aaaFilePath, '''
 import 'dart:math' show max, pi, Random hide min;
@@ -1322,7 +1322,7 @@
     newFile(partPathA, codeA);
     newFile(partPathB, codeB);
 
-    pathForContextSelection = testFilePath;
+    pathForContextSelection = testFile.path;
 
     await resolveFileCode(libPath, '''
 library lib;
@@ -1395,7 +1395,7 @@
         ..add(name: 'aaa', rootPath: aaaPackageRootPath),
     );
 
-    pathForContextSelection = testFilePath;
+    pathForContextSelection = testFile.path;
 
     await resolveFileCode(testPath, '''
 main() {
@@ -1865,7 +1865,7 @@
         ..add(name: 'aaa', rootPath: aaaPackageRootPath),
     );
 
-    pathForContextSelection = testFilePath;
+    pathForContextSelection = testFile.path;
 
     var libPath = convertPath('$aaaPackageRootPath/lib/a.dart');
     var partPath = convertPath('$aaaPackageRootPath/lib/my_part.dart');
@@ -1978,7 +1978,7 @@
         ..add(name: 'aaa', rootPath: aaaPackageRootPath),
     );
 
-    pathForContextSelection = testFilePath;
+    pathForContextSelection = this.testFile.path;
 
     String testCode = '''
 library lib;
@@ -2408,7 +2408,7 @@
     var aUri = 'package:aaa/a.dart';
     var bUri = 'package:bbb/b.dart';
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 import 'package:aaa/a.dart';
 
 class T1 extends A {
@@ -2476,7 +2476,7 @@
         ..add(name: 'bbb', rootPath: bbbPackageRootPath),
     );
 
-    newFile(testFilePath, 'class T implements List {}');
+    addTestFile('class T implements List {}');
     newFile(aaaFilePath, 'class A implements List {}');
     newFile(bbbFilePath, 'class B implements List {}');
     newFile(cccFilePath, 'class C implements List {}');
@@ -2496,7 +2496,7 @@
       expect(results, not ? isNot(matcher) : matcher);
     }
 
-    assertHasResult(convertPath(testFilePath), 'T');
+    assertHasResult(testFile.path, 'T');
     assertHasResult(aaaFilePath, 'A');
     assertHasResult(bbbFilePath, 'B');
     assertHasResult(cccFilePath, 'C', not: true);
diff --git a/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart b/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
index f03c5fa..8af5849 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
@@ -23,7 +23,7 @@
   @override
   void setUp() {
     super.setUp();
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     helper = AnalysisSessionHelper(session);
   }
 
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index d0708d1..4a1a014 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -183,9 +183,9 @@
   }
 
   test_getErrors() async {
-    var test = newFile(testFilePath, 'class C {');
+    var test = newFile(testFile.path, 'class C {');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var errorsResult = await session.getErrorsValid(test.path);
     expect(errorsResult.session, session);
     expect(errorsResult.path, test.path);
@@ -193,7 +193,7 @@
   }
 
   test_getErrors_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -203,13 +203,13 @@
   }
 
   test_getErrors_invalidPath_notAbsolute() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var errorsResult = await session.getErrors('not_absolute.dart');
     expect(errorsResult, isA<InvalidPathResult>());
   }
 
   test_getFile_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -219,7 +219,7 @@
   }
 
   test_getFile_invalidPath_notAbsolute() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var errorsResult = session.getFile('not_absolute.dart');
     expect(errorsResult, isA<InvalidPathResult>());
   }
@@ -227,7 +227,7 @@
   test_getFile_library() async {
     var a = newFile('$testPackageLibPath/a.dart', '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var file = session.getFileValid(a.path);
     expect(file.path, a.path);
     expect(file.uri.toString(), 'package:test/a.dart');
@@ -237,7 +237,7 @@
   test_getFile_part() async {
     var a = newFile('$testPackageLibPath/a.dart', 'part of lib;');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var file = session.getFileValid(a.path);
     expect(file.path, a.path);
     expect(file.uri.toString(), 'package:test/a.dart');
@@ -245,12 +245,12 @@
   }
 
   test_getLibraryByUri() async {
-    newFile(testFilePath, r'''
+    newFile(testFile.path, r'''
 class A {}
 class B {}
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var result = await session.getLibraryByUriValid('package:test/test.dart');
     var library = result.element;
     expect(library.getType('A'), isNotNull);
@@ -259,7 +259,7 @@
   }
 
   test_getLibraryByUri_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -269,27 +269,27 @@
   }
 
   test_getLibraryByUri_notLibrary_augmentation() async {
-    newFile(testFilePath, r'''
+    newFile(testFile.path, r'''
 library augment 'a.dart';
 ''');
 
-    final session = contextFor(testFilePath).currentSession;
+    final session = contextFor(testFile.path).currentSession;
     final result = await session.getLibraryByUri('package:test/test.dart');
     expect(result, isA<NotLibraryButAugmentationResult>());
   }
 
   test_getLibraryByUri_notLibrary_part() async {
-    newFile(testFilePath, r'''
+    newFile(testFile.path, r'''
 part of 'a.dart';
 ''');
 
-    final session = contextFor(testFilePath).currentSession;
+    final session = contextFor(testFile.path).currentSession;
     final result = await session.getLibraryByUri('package:test/test.dart');
     expect(result, isA<NotLibraryButPartResult>());
   }
 
   test_getLibraryByUri_unresolvedUri() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var result = await session.getLibraryByUri('package:foo/foo.dart');
     expect(result, isA<CannotResolveUriResult>());
   }
@@ -300,7 +300,7 @@
 class B {}
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var parsedLibrary = session.getParsedLibraryValid(test.path);
     expect(parsedLibrary.session, session);
 
@@ -315,12 +315,12 @@
   }
 
   test_getParsedLibrary_getElementDeclaration_class() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 class A {}
 class B {}
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
       'package:test/test.dart',
     );
@@ -335,9 +335,9 @@
   }
 
   test_getParsedLibrary_getElementDeclaration_notThisLibrary() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var resolvedUnit =
         await session.getResolvedUnit(test.path) as ResolvedUnitResult;
     var typeProvider = resolvedUnit.typeProvider;
@@ -351,11 +351,11 @@
   }
 
   test_getParsedLibrary_getElementDeclaration_synthetic() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 int foo = 0;
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var parsedLibrary = session.getParsedLibraryValid(test.path);
 
     var unitResult = await session.getUnitElementValid(test.path);
@@ -376,7 +376,7 @@
   }
 
   test_getParsedLibrary_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -386,13 +386,13 @@
   }
 
   test_getParsedLibrary_invalidPartUri() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 part 'a.dart';
 part ':[invalid uri].dart';
 part 'c.dart';
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var parsedLibrary = session.getParsedLibraryValid(test.path);
 
     expect(parsedLibrary.units, hasLength(1));
@@ -403,23 +403,23 @@
   }
 
   test_getParsedLibrary_invalidPath_notAbsolute() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var result = session.getParsedLibrary('not_absolute.dart');
     expect(result, isA<InvalidPathResult>());
   }
 
   test_getParsedLibrary_notLibrary() async {
-    var test = newFile(testFilePath, 'part of "a.dart";');
-    var session = contextFor(testFilePath).currentSession;
+    var test = newFile(testFile.path, 'part of "a.dart";');
+    var session = contextFor(testFile.path).currentSession;
     expect(session.getParsedLibrary(test.path), isA<NotLibraryButPartResult>());
   }
 
   test_getParsedLibrary_notLibrary_augmentation() async {
-    newFile(testFilePath, r'''
+    newFile(testFile.path, r'''
 library augment 'a.dart';
 ''');
 
-    final session = contextFor(testFilePath).currentSession;
+    final session = contextFor(testFile.path).currentSession;
     final result = session.getParsedLibrary(testFile.path);
     expect(result, isA<NotLibraryButAugmentationResult>());
   }
@@ -451,7 +451,7 @@
     var b = newFile('$testPackageLibPath/b.dart', bContent);
     var c = newFile('$testPackageLibPath/c.dart', cContent);
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var parsedLibrary = session.getParsedLibraryValid(a.path);
     expect(parsedLibrary.units, hasLength(3));
 
@@ -478,9 +478,9 @@
   }
 
   test_getParsedLibraryByElement() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
       'package:test/test.dart',
     );
@@ -499,9 +499,9 @@
   }
 
   test_getParsedLibraryByElement_differentSession() async {
-    newFile(testFilePath, '');
+    newFile(testFile.path, '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
       'package:test/test.dart',
     );
@@ -514,12 +514,12 @@
   }
 
   test_getParsedUnit() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 class A {}
 class B {}
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var unitResult = session.getParsedUnitValid(test.path);
     expect(unitResult.session, session);
     expect(unitResult.path, test.path);
@@ -528,7 +528,7 @@
   }
 
   test_getParsedUnit_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -538,7 +538,7 @@
   }
 
   test_getParsedUnit_invalidPath_notAbsolute() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var result = session.getParsedUnit('not_absolute.dart');
     expect(result, isA<InvalidPathResult>());
   }
@@ -559,7 +559,7 @@
 ''';
     var b = newFile('$testPackageLibPath/b.dart', bContent);
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var resolvedLibrary = await session.getResolvedLibraryValid(a.path);
     expect(resolvedLibrary.session, session);
 
@@ -606,9 +606,9 @@
   }
 
   test_getResolvedLibrary_getElementDeclaration_notThisLibrary() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var resolvedLibrary = await session.getResolvedLibraryValid(test.path);
 
     expect(() {
@@ -618,11 +618,11 @@
   }
 
   test_getResolvedLibrary_getElementDeclaration_synthetic() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 int foo = 0;
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var resolvedLibrary = await session.getResolvedLibraryValid(test.path);
     var unitElement = resolvedLibrary.element.definingCompilationUnit;
 
@@ -643,7 +643,7 @@
   }
 
   test_getResolvedLibrary_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -653,13 +653,13 @@
   }
 
   test_getResolvedLibrary_invalidPartUri() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 part 'a.dart';
 part ':[invalid uri].dart';
 part 'c.dart';
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var resolvedLibrary = await session.getResolvedLibraryValid(test.path);
 
     expect(resolvedLibrary.units, hasLength(1));
@@ -670,33 +670,33 @@
   }
 
   test_getResolvedLibrary_invalidPath_notAbsolute() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var result = await session.getResolvedLibrary('not_absolute.dart');
     expect(result, isA<InvalidPathResult>());
   }
 
   test_getResolvedLibrary_notLibrary_augmentation() async {
-    newFile(testFilePath, r'''
+    newFile(testFile.path, r'''
 library augment of 'a.dart';
 ''');
 
-    final session = contextFor(testFilePath).currentSession;
+    final session = contextFor(testFile.path).currentSession;
     final result = await session.getResolvedLibrary(testFile.path);
     expect(result, isA<NotLibraryButAugmentationResult>());
   }
 
   test_getResolvedLibrary_notLibrary_part() async {
-    var test = newFile(testFilePath, 'part of "a.dart";');
+    var test = newFile(testFile.path, 'part of "a.dart";');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var result = await session.getResolvedLibrary(test.path);
     expect(result, isA<NotLibraryButPartResult>());
   }
 
   test_getResolvedLibraryByElement() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
       'package:test/test.dart',
     );
@@ -711,9 +711,9 @@
   }
 
   test_getResolvedLibraryByElement_differentSession() async {
-    newFile(testFilePath, '');
+    newFile(testFile.path, '');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
       'package:test/test.dart',
     );
@@ -726,12 +726,12 @@
   }
 
   test_getResolvedUnit() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 class A {}
 class B {}
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var unitResult =
         await session.getResolvedUnit(test.path) as ResolvedUnitResult;
     expect(unitResult.session, session);
@@ -743,7 +743,7 @@
   }
 
   test_getResolvedUnit_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -753,12 +753,12 @@
   }
 
   test_getUnitElement() async {
-    var test = newFile(testFilePath, r'''
+    var test = newFile(testFile.path, r'''
 class A {}
 class B {}
 ''');
 
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     var unitResult = await session.getUnitElementValid(test.path);
     expect(unitResult.session, session);
     expect(unitResult.path, test.path);
@@ -767,7 +767,7 @@
   }
 
   test_getUnitElement_inconsistent() async {
-    var test = newFile(testFilePath, '');
+    var test = newFile(testFile.path, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -777,7 +777,7 @@
   }
 
   test_resourceProvider() async {
-    var session = contextFor(testFilePath).currentSession;
+    var session = contextFor(testFile.path).currentSession;
     expect(session.resourceProvider, resourceProvider);
   }
 }
diff --git a/pkg/analyzer/test/src/dart/micro/file_resolution.dart b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
index a500588..f02a94e 100644
--- a/pkg/analyzer/test/src/dart/micro/file_resolution.dart
+++ b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
@@ -28,8 +28,6 @@
 
 /// [FileResolver] based implementation of [ResolutionTest].
 class FileResolutionTest with ResourceProviderMixin, ResolutionTest {
-  static final String _testFile = '/workspace/dart/test/lib/test.dart';
-
   final MemoryByteStore byteStore = MemoryByteStore();
 
   final FileResolverTestData testData = FileResolverTestData();
@@ -49,10 +47,8 @@
 
   Folder get sdkRoot => newFolder('/sdk');
 
-  File get testFile => getFile(testFilePath);
-
   @override
-  String get testFilePath => _testFile;
+  File get testFile => getFile('$testPackageLibPath/test.dart');
 
   String get testPackageLibPath => '$testPackageRootPath/lib';
 
@@ -62,7 +58,7 @@
 
   @override
   void addTestFile(String content) {
-    newFile(_testFile, content);
+    newFile(testFile.path, content);
   }
 
   void assertStateString(
@@ -94,7 +90,7 @@
   void createFileResolver() {
     var workspace = BazelWorkspace.find(
       resourceProvider,
-      convertPath(_testFile),
+      testFile.path,
     )!;
 
     fileResolver = FileResolver(
@@ -114,8 +110,7 @@
   }
 
   Future<ErrorsResult> getTestErrors() async {
-    var path = convertPath(_testFile);
-    return fileResolver.getErrors2(path: path);
+    return fileResolver.getErrors2(path: testFile.path);
   }
 
   @override
@@ -132,8 +127,7 @@
 
   @override
   Future<void> resolveTestFile() async {
-    var path = convertPath(_testFile);
-    result = await resolveFile(path);
+    result = await resolveFile(testFile.path);
     findNode = FindNode(result.content, result.unit);
     findElement = FindElement(result.unit);
   }
diff --git a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
index cdf927c..56b63a6 100644
--- a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
+++ b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
@@ -1316,7 +1316,7 @@
   }
 
   test_getErrors_reuse() async {
-    newFile(testFilePath, 'var a = b;');
+    addTestFile('var a = b;');
 
     // No resolved files yet.
     _assertResolvedFiles([]);
@@ -1330,7 +1330,7 @@
     _assertResolvedFiles([]);
 
     // Change the file, will be resolved again.
-    newFile(testFilePath, 'var a = c;');
+    addTestFile('var a = c;');
     fileResolver.changeFiles([testFile.path]);
     expect((await getTestErrors()).errors, hasLength(1));
     _assertResolvedFiles([testFile]);
@@ -1341,7 +1341,7 @@
 var a = 0;
 ''');
 
-    newFile(testFilePath, r'''
+    addTestFile(r'''
 import 'a.dart';
 var b = a.foo;
 ''');
@@ -2369,7 +2369,7 @@
   }
 
   test_resolveFile_cache() async {
-    newFile(testFilePath, 'var a = 0;');
+    addTestFile('var a = 0;');
 
     // No resolved files yet.
     _assertResolvedFiles([]);
diff --git a/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart b/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart
index cedb204..de92432 100644
--- a/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart
@@ -45,7 +45,7 @@
     uri: DirectiveUriWithAugmentation
       uri: package:test/c.dart
   uriContent: c.dart
-  uriElement: package:test/a.dart::@augmentation::package:test/c.dart
+  uriElement: self::@augmentation::package:test/c.dart
   uriSource: package:test/c.dart
 ''');
   }
@@ -82,7 +82,7 @@
     uri: DirectiveUriWithAugmentation
       uri: package:test/c.dart
   uriContent: c.dart
-  uriElement: package:test/a.dart::@augmentation::package:test/c.dart
+  uriElement: self::@augmentation::package:test/c.dart
   uriSource: package:test/c.dart
 ''');
   }
diff --git a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
index ef1870b..5165f8a 100644
--- a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
@@ -97,7 +97,7 @@
   String get myPackageRootPath => '$workspaceRootPath/dart/my';
 
   @override
-  String get testFilePath => '$myPackageLibPath/my.dart';
+  File get testFile => getFile('$myPackageLibPath/my.dart');
 
   String get workspaceRootPath => '/workspace';
 
@@ -115,7 +115,7 @@
   @override
   void verifyCreatedCollection() {
     super.verifyCreatedCollection();
-    assertBazelWorkspaceFor(testFilePath);
+    assertBazelWorkspaceFor(testFile);
   }
 }
 
@@ -157,13 +157,13 @@
 
   Folder get sdkRoot => newFolder('/sdk');
 
-  void assertBasicWorkspaceFor(String path) {
-    var workspace = contextFor(path).contextRoot.workspace;
+  void assertBasicWorkspaceFor(File file) {
+    var workspace = contextFor(file.path).contextRoot.workspace;
     expect(workspace, TypeMatcher<BasicWorkspace>());
   }
 
-  void assertBazelWorkspaceFor(String path) {
-    var workspace = contextFor(path).contextRoot.workspace;
+  void assertBazelWorkspaceFor(File file) {
+    var workspace = contextFor(file.path).contextRoot.workspace;
     expect(workspace, TypeMatcher<BazelWorkspace>());
   }
 
@@ -193,13 +193,13 @@
     expect(actual, expected);
   }
 
-  void assertGnWorkspaceFor(String path) {
-    var workspace = contextFor(path).contextRoot.workspace;
+  void assertGnWorkspaceFor(File file) {
+    var workspace = contextFor(file.path).contextRoot.workspace;
     expect(workspace, TypeMatcher<GnWorkspace>());
   }
 
-  void assertPackageBuildWorkspaceFor(String path) {
-    var workspace = contextFor(path).contextRoot.workspace;
+  void assertPackageBuildWorkspaceFor(File file) {
+    var workspace = contextFor(file.path).contextRoot.workspace;
     expect(workspace, TypeMatcher<PackageBuildWorkspace>());
   }
 
@@ -332,10 +332,8 @@
   /// The path that is not in [workspaceRootPath], contains external packages.
   String get packagesRootPath => '/packages';
 
-  File get testFile => getFile(testFilePath);
-
   @override
-  String get testFilePath => '$testPackageLibPath/test.dart';
+  File get testFile => getFile('$testPackageLibPath/test.dart');
 
   /// The language version to use by default for `package:test`.
   String? get testPackageLanguageVersion => null;
diff --git a/pkg/analyzer/test/src/dart/resolution/library_augmentation_test.dart b/pkg/analyzer/test/src/dart/resolution/library_augmentation_test.dart
index d115d4b..bb3d51c 100644
--- a/pkg/analyzer/test/src/dart/resolution/library_augmentation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/library_augmentation_test.dart
@@ -37,7 +37,7 @@
   uri: SimpleStringLiteral
     literal: 'a.dart'
   semicolon: ;
-  element: package:test/a.dart::@augmentation::package:test/b.dart
+  element: self::@augmentation::package:test/b.dart
 ''');
   }
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
index 08b5846..dc0c9bc 100644
--- a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
@@ -4,6 +4,7 @@
 
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/test_utilities/find_element.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -43,72 +44,7 @@
 ''');
   }
 
-  test_location_partDirective() async {
-    newFile('$testPackageLibPath/a.dart', r'''
-part of 'test.dart';
-''');
-
-    await assertNoErrorsInCode(r'''
-@foo
-part 'a.dart';
-const foo = 42;
-''');
-
-    var annotation = findNode.annotation('@foo');
-    assertResolvedNodeText(annotation, r'''
-Annotation
-  atSign: @
-  name: SimpleIdentifier
-    token: foo
-    staticElement: self::@getter::foo
-    staticType: null
-  element: self::@getter::foo
-''');
-
-    var annotationElement = annotation.elementAnnotation!;
-    _assertElementAnnotationValueText(annotationElement, r'''
-int 42
-  variable: self::@variable::foo
-''');
-  }
-
-  test_location_partOfDirective() async {
-    var libPath = newFile('$testPackageLibPath/lib.dart', r'''
-part 'part.dart';
-''').path;
-
-    var partPath = newFile('$testPackageLibPath/part.dart', r'''
-@foo
-part of 'lib.dart';
-const foo = 42;
-void f() {}
-''').path;
-
-    // Resolve the library, so that the part knows its library.
-    await resolveFile2(libPath);
-
-    await resolveFile2(partPath);
-    assertNoErrorsInResult();
-
-    var annotation = findNode.annotation('@foo');
-    assertResolvedNodeText(annotation, r'''
-Annotation
-  atSign: @
-  name: SimpleIdentifier
-    token: foo
-    staticElement: package:test/lib.dart::@getter::foo
-    staticType: null
-  element: package:test/lib.dart::@getter::foo
-''');
-
-    var annotationElement = annotation.elementAnnotation!;
-    _assertElementAnnotationValueText(annotationElement, r'''
-int 42
-  variable: self::@variable::foo
-''');
-  }
-
-  test_onEnumConstant() async {
+  test_location_enumConstant() async {
     await assertNoErrorsInCode(r'''
 enum E {
   @v
@@ -135,7 +71,19 @@
 ''');
   }
 
-  test_onFieldFormal() async {
+  test_location_exportLibraryDirective() async {
+    newFile('$testPackageLibPath/a.dart', '');
+
+    await assertNoErrorsInCode(r'''
+@foo
+export 'a.dart';
+const foo = 42;
+''');
+
+    _assertAtFoo42();
+  }
+
+  test_location_fieldFormal() async {
     await assertNoErrorsInCode(r'''
 class A {
   final Object f;
@@ -187,7 +135,60 @@
 ''');
   }
 
-  test_onLocalVariable() async {
+  test_location_importAugmentationDirective() async {
+    newFile('$testPackageLibPath/a.dart', r'''
+library augment 'test.dart';
+''');
+
+    await assertNoErrorsInCode(r'''
+@foo
+import augment 'a.dart';
+const foo = 42;
+''');
+
+    _assertAtFoo42();
+  }
+
+  test_location_importLibraryDirective() async {
+    newFile('$testPackageLibPath/a.dart', '');
+
+    await assertNoErrorsInCode(r'''
+@foo
+import 'a.dart'; // ignore:unused_import
+const foo = 42;
+''');
+
+    _assertAtFoo42();
+  }
+
+  test_location_libraryAugmentationDirective() async {
+    newFile('$testPackageLibPath/test.dart', r'''
+import augment 'a.dart';
+const foo = 42;
+''');
+
+    var a = newFile('$testPackageLibPath/a.dart', r'''
+@foo
+library augment 'test.dart';
+''');
+
+    await resolveFile2(a.path);
+    assertNoErrorsInResult();
+
+    _assertAtFoo42();
+  }
+
+  test_location_libraryDirective() async {
+    await assertNoErrorsInCode(r'''
+@foo
+library my;
+const foo = 42;
+''');
+
+    _assertAtFoo42();
+  }
+
+  test_location_localVariable() async {
     await assertNoErrorsInCode(r'''
 class A {
   final int a;
@@ -228,6 +229,49 @@
 ''');
   }
 
+  test_location_partDirective() async {
+    newFile('$testPackageLibPath/a.dart', r'''
+part of 'test.dart';
+''');
+
+    await assertNoErrorsInCode(r'''
+@foo
+part 'a.dart';
+const foo = 42;
+''');
+
+    _assertAtFoo42();
+  }
+
+  test_location_partDirective_fileDoesNotExist() async {
+    await assertErrorsInCode(r'''
+@foo
+part 'a.dart';
+const foo = 42;
+''', [
+      error(CompileTimeErrorCode.URI_DOES_NOT_EXIST, 10, 8),
+    ]);
+
+    _assertAtFoo42();
+  }
+
+  test_location_partOfDirective() async {
+    newFile('$testPackageLibPath/test.dart', r'''
+part 'a.dart';
+const foo = 42;
+''');
+
+    var a = newFile('$testPackageLibPath/a.dart', r'''
+@foo
+part of 'test.dart';
+''');
+
+    await resolveFile2(a.path);
+    assertNoErrorsInResult();
+
+    _assertAtFoo42();
+  }
+
   test_optIn_fromOptOut_class() async {
     newFile('$testPackageLibPath/a.dart', r'''
 class A {
@@ -2570,6 +2614,25 @@
     _assertElementAnnotationValueText(elementAnnotation, expected);
   }
 
+  void _assertAtFoo42() {
+    final node = findNode.annotation('@foo');
+    assertResolvedNodeText(node, r'''
+Annotation
+  atSign: @
+  name: SimpleIdentifier
+    token: foo
+    staticElement: self::@getter::foo
+    staticType: null
+  element: self::@getter::foo
+''');
+
+    final element = node.elementAnnotation!;
+    _assertElementAnnotationValueText(element, r'''
+int 42
+  variable: self::@variable::foo
+''');
+  }
+
   void _assertElementAnnotationValueText(
     ElementAnnotation annotation,
     String expected,
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 0872e4c..e101a50 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -11,6 +11,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/error.dart';
+import 'package:analyzer/file_system/file_system.dart';
 import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/constant/value.dart';
 import 'package:analyzer/src/dart/element/element.dart';
@@ -78,7 +79,7 @@
 
   InterfaceType get stringType => typeProvider.stringType;
 
-  String get testFilePath => '/test/lib/test.dart';
+  File get testFile;
 
   TypeProvider get typeProvider => result.typeProvider;
 
@@ -87,7 +88,7 @@
   VoidType get voidType => VoidTypeImpl.instance;
 
   void addTestFile(String content) {
-    newFile(testFilePath, content);
+    newFile(testFile.path, content);
   }
 
   /// Assert that the given [identifier] is a reference to a class, in the
@@ -762,7 +763,7 @@
   }
 
   Future<void> resolveTestFile() {
-    return resolveFile2(testFilePath);
+    return resolveFile2(testFile.path);
   }
 
   /// Choose the type display string, depending on whether the [result] is
@@ -810,7 +811,7 @@
     var buffer = StringBuffer();
     node.accept(
       ResolvedAstPrinter(
-        selfUriStr: result.uri.toString(),
+        selfUriStr: '${result.libraryElement.source.uri}',
         sink: buffer,
         indent: '',
         skipArgumentList: skipArgumentList,
diff --git a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
index a2dee38..61e6d02 100644
--- a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
@@ -2,6 +2,7 @@
 // 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 'package:analyzer/file_system/file_system.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -324,7 +325,7 @@
   @override
   void verifyCreatedCollection() {
     super.verifyCreatedCollection();
-    assertBasicWorkspaceFor(testFilePath);
+    assertBasicWorkspaceFor(testFile);
   }
 }
 
@@ -352,7 +353,7 @@
 class A {}
 ''');
 
-    assertBazelWorkspaceFor(testFilePath);
+    assertBazelWorkspaceFor(testFile);
 
     await assertErrorsInCode(r'''
 import 'package:aaa/a.dart';
@@ -374,7 +375,7 @@
   String get myPackageRootPath => '$workspaceRootPath/my';
 
   @override
-  String get testFilePath => '$myPackageLibPath/my.dart';
+  File get testFile => getFile('$myPackageLibPath/my.dart');
 
   String get workspaceRootPath => '/workspace';
 
@@ -435,7 +436,7 @@
   @override
   void verifyCreatedCollection() {
     super.verifyCreatedCollection();
-    assertGnWorkspaceFor(testFilePath);
+    assertGnWorkspaceFor(testFile);
   }
 
   void _writeWorkspacePackagesFile(Map<String, String> nameToLibPath) {
@@ -1625,7 +1626,7 @@
   @override
   void verifyCreatedCollection() {
     super.verifyCreatedCollection();
-    assertPackageBuildWorkspaceFor(testFilePath);
+    assertPackageBuildWorkspaceFor(testFile);
   }
 
   void _createTestPackageBuildMarker() {
diff --git a/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart b/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart
index d80cb61..53c6dfd 100644
--- a/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart
@@ -51,7 +51,7 @@
   }
 
   Future<ResolvedLibraryResult> _resolvedLibraryByUri(String uriStr) async {
-    var analysisSession = contextFor(testFilePath).currentSession;
+    var analysisSession = contextFor(testFile.path).currentSession;
     var coreElementResult =
         await analysisSession.getLibraryByUri(uriStr) as LibraryElementResult;
     return await analysisSession.getResolvedLibraryByElement(
diff --git a/pkg/analyzer/test/src/diagnostics/null_safety_read_write_test.dart b/pkg/analyzer/test/src/diagnostics/null_safety_read_write_test.dart
index b4dece1..88087f5 100644
--- a/pkg/analyzer/test/src/diagnostics/null_safety_read_write_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/null_safety_read_write_test.dart
@@ -1217,7 +1217,7 @@
   }) {
     var node = findNode.simple(search);
 
-    var testingData = driverFor(testFilePath).testingData!;
+    var testingData = driverFor(testFile.path).testingData!;
     var unitData = testingData.uriToFlowAnalysisData[result.uri]!;
 
     if (assigned) {
diff --git a/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart b/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart
index 25f897b..f0d36fc 100644
--- a/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart
@@ -59,7 +59,7 @@
     // Remove the overlay in the same way as AnalysisServer.
     deleteFile(filePath);
 
-    var analysisDriver = driverFor(testFilePath);
+    var analysisDriver = driverFor(testFile.path);
     analysisDriver.removeFile(filePath);
     await analysisDriver.applyPendingFileChanges();
 
diff --git a/pkg/analyzer/test/src/summary/elements_base.dart b/pkg/analyzer/test/src/summary/elements_base.dart
index 87eff04..9a3db3b 100644
--- a/pkg/analyzer/test/src/summary/elements_base.dart
+++ b/pkg/analyzer/test/src/summary/elements_base.dart
@@ -26,7 +26,7 @@
     bool dumpSummaries = false,
     List<Set<String>>? preBuildSequence,
   }) async {
-    final file = newFile(testFilePath, text);
+    final file = newFile(testFile.path, text);
     final analysisContext = contextFor(file.path);
     final analysisSession = analysisContext.currentSession;
 
diff --git a/pkg/analyzer/test/src/summary/elements_test.dart b/pkg/analyzer/test/src/summary/elements_test.dart
index 3dbecde..0c04b60 100644
--- a/pkg/analyzer/test/src/summary/elements_test.dart
+++ b/pkg/analyzer/test/src/summary/elements_test.dart
@@ -27446,6 +27446,31 @@
 ''');
   }
 
+  test_metadata_augmentation_libraryAugmentation() async {
+    newFile('$testPackageLibPath/a.dart', r'''
+@deprecated
+library augment 'test.dart';
+''');
+    final library = await buildLibrary('''
+import augment 'a.dart';
+''');
+    checkElementText(library, r'''
+library
+  augmentationImports
+    package:test/a.dart
+      metadata
+        Annotation
+          atSign: @ @0
+          name: SimpleIdentifier
+            token: deprecated @1
+            staticElement: dart:core::@getter::deprecated
+            staticType: null
+          element: dart:core::@getter::deprecated
+      definingUnit
+  definingUnit
+''');
+  }
+
   test_metadata_class_field_first() async {
     var library = await buildLibrary(r'''
 const a = 0;
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index dfe5949..712f520 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -6163,11 +6163,10 @@
   }
 
   Future<LibraryElement> _encodeDecodeLibrary(String text) async {
-    newFile(testFilePath, text);
+    newFile(testFile.path, text);
 
-    var path = convertPath(testFilePath);
-    var analysisSession = contextFor(path).currentSession;
-    var result = await analysisSession.getUnitElement(path);
+    var analysisSession = contextFor(testFile.path).currentSession;
+    var result = await analysisSession.getUnitElement(testFile.path);
     result as UnitElementResult;
     return result.element.library;
   }
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index c6edd7f..05b4002 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -2941,7 +2941,7 @@
       error(HintCode.UNUSED_ELEMENT, 177, 2),
       error(HintCode.UNUSED_ELEMENT, 194, 2),
       error(CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION, 203, 2,
-          contextMessages: [message(testFilePath, 211, 2)]),
+          contextMessages: [message(testFile.path, 211, 2)]),
     ]);
 
     void assertLocalFunctionType(String name, String expected) {
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 0789bff..5e5cc6c 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -20,13 +20,13 @@
 import 'common/names.dart' show Selectors;
 import 'common/tasks.dart' show CompilerTask, GenericTask, Measurer;
 import 'common/work.dart' show WorkItem;
+import 'compiler_interfaces.dart'
+    show CompilerDeferredLoadingFacade, CompilerDiagnosticsFacade;
 import 'deferred_load/deferred_load.dart' show DeferredLoadTask;
 import 'deferred_load/output_unit.dart' show OutputUnitData;
 import 'deferred_load/program_split_constraints/nodes.dart' as psc
     show ConstraintData;
 import 'deferred_load/program_split_constraints/parser.dart' as psc show Parser;
-import 'diagnostics/compiler_diagnostics_facade.dart'
-    show CompilerDiagnosticsFacade;
 import 'diagnostics/messages.dart' show Message;
 import 'dump_info.dart' show DumpInfoStateData, DumpInfoTask;
 import 'elements/entities.dart';
@@ -65,11 +65,14 @@
 
 /// Implementation of the compiler using  a [api.CompilerInput] for supplying
 /// the sources.
-class Compiler implements CompilerDiagnosticsFacade {
+class Compiler
+    implements CompilerDiagnosticsFacade, CompilerDeferredLoadingFacade {
+  @override
   final Measurer measurer;
   final api.CompilerInput provider;
   final api.CompilerDiagnostics handler;
 
+  @override
   KernelFrontendStrategy frontendStrategy;
   JsBackendStrategy backendStrategy;
   /*late*/ DiagnosticReporter _reporter;
@@ -89,6 +92,7 @@
   /// Output provider from user of Compiler API.
   api.CompilerOutput _outputProvider;
 
+  @override
   api.CompilerOutput get outputProvider => _outputProvider;
 
   ir.Component componentForTesting;
@@ -100,7 +104,9 @@
 
   ir.Component untrimmedComponentForDumpInfo;
 
+  @override
   DiagnosticReporter get reporter => _reporter;
+  @override
   Map<Entity, WorldImpact> get impactCache => _impactCache;
 
   final Environment environment;
@@ -132,6 +138,7 @@
   @override // CompilerDiagnosticsFacade
   bool compilationFailed = false;
 
+  @override
   psc.ConstraintData programSplitConstraintsData;
 
   // Callback function used for testing resolution enqueuing.
diff --git a/pkg/compiler/lib/src/compiler_interfaces.dart b/pkg/compiler/lib/src/compiler_interfaces.dart
new file mode 100644
index 0000000..f62faab
--- /dev/null
+++ b/pkg/compiler/lib/src/compiler_interfaces.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+/// Facades for [Compiler] used from other parts of the system.
+// TODO(48820): delete after the migration is complete.
+library compiler.src.compiler_interfaces;
+
+import '../compiler_api.dart' show CompilerOutput, Diagnostic;
+
+import 'common/tasks.dart' show Measurer;
+import 'deferred_load/program_split_constraints/nodes.dart' show ConstraintData;
+import 'diagnostics/diagnostic_listener.dart' show DiagnosticMessage;
+import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter;
+import 'diagnostics/source_span.dart';
+import 'diagnostics/spannable.dart';
+import 'elements/entities.dart' show Entity;
+import 'kernel/kernel_strategy_migrated.dart'
+    show KernelFrontendStrategyForDeferredLoading;
+import 'options.dart' show CompilerOptions;
+import 'universe/world_impact.dart' show WorldImpact;
+
+/// Subset of [Compiler] needed by deferred loading.
+///
+/// See definitions on [Compiler] for documentation.
+abstract class CompilerDeferredLoadingFacade {
+  bool get compilationFailed;
+  Measurer get measurer;
+  DiagnosticReporter get reporter;
+  Map<Entity, WorldImpact> get impactCache;
+  CompilerOptions get options;
+  KernelFrontendStrategyForDeferredLoading get frontendStrategy;
+  CompilerOutput get outputProvider;
+  ConstraintData? get programSplitConstraintsData;
+}
+
+/// Subset of [Compiler] needed by `DiagnosticListener`.
+///
+/// See definitions on [Compiler] for documentation.
+abstract class CompilerDiagnosticsFacade {
+  CompilerOptions get options;
+
+  bool inUserCode(Entity element);
+
+  Uri getCanonicalUri(Entity element);
+
+  void reportDiagnostic(DiagnosticMessage message,
+      List<DiagnosticMessage> infos, Diagnostic kind);
+
+  void fatalDiagnosticReported(DiagnosticMessage message,
+      List<DiagnosticMessage> infos, Diagnostic kind);
+
+  bool get compilationFailed;
+
+  SourceSpan spanFromSpannable(Spannable spannable, Entity? currentElement);
+}
diff --git a/pkg/compiler/lib/src/deferred_load/algorithm_state.dart b/pkg/compiler/lib/src/deferred_load/algorithm_state.dart
index b5d7726..142a766 100644
--- a/pkg/compiler/lib/src/deferred_load/algorithm_state.dart
+++ b/pkg/compiler/lib/src/deferred_load/algorithm_state.dart
@@ -2,18 +2,21 @@
 // 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.
 
-// @dart = 2.10
-
 import 'entity_data.dart';
 import 'entity_data_info.dart';
 import 'import_set.dart';
 import 'work_queue.dart';
 
 import '../common.dart';
-import '../compiler.dart' show Compiler;
+import '../compiler_interfaces.dart' show CompilerDeferredLoadingFacade;
 import '../elements/entities.dart';
-import '../kernel/element_map.dart';
-import '../kernel/kernel_world.dart';
+import '../kernel/element_map_interfaces.dart'
+    show KernelToElementMapForDeferredLoading;
+import '../kernel/kernel_world_interfaces.dart' show KClosedWorld;
+
+// TODO(48820): delete typedef after the migration is complete.
+typedef Compiler = CompilerDeferredLoadingFacade;
+typedef KernelToElementMap = KernelToElementMapForDeferredLoading;
 
 /// Manages the state of the [EntityData] model. Every class, member, constant,
 /// etc, is wrapped in the deferred loading algorithm by an [EntityData] which
@@ -109,7 +112,7 @@
   void _updateDependencies(
       EntityData entityData, ImportSet oldSet, ImportSet newSet) {
     assert(directDependencies.containsKey(entityData));
-    var directDependenciesList = directDependencies[entityData];
+    var directDependenciesList = directDependencies[entityData]!;
     for (var entity in directDependenciesList) {
       update(entity, oldSet, newSet);
     }
@@ -148,7 +151,7 @@
     var imports = entityToSet.values.toSet();
     var finalTransitions = importSets.computeFinalTransitions(imports);
     for (var key in entityToSet.keys) {
-      entityToSet[key] = finalTransitions[entityToSet[key]];
+      entityToSet[key] = finalTransitions[entityToSet[key]]!;
     }
   }
 }
diff --git a/pkg/compiler/lib/src/deferred_load/deferred_load.dart b/pkg/compiler/lib/src/deferred_load/deferred_load.dart
index 1928dd8..0499e5f 100644
--- a/pkg/compiler/lib/src/deferred_load/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load/deferred_load.dart
@@ -2,8 +2,6 @@
 // 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.
 
-// @dart = 2.10
-
 /// *Overview of deferred loading*
 ///
 /// Deferred loading allows developers to specify deferred imports. These
@@ -283,14 +281,19 @@
 import '../common/metrics.dart'
     show Metric, Metrics, CountMetric, DurationMetric;
 import '../common/tasks.dart' show CompilerTask;
-import '../compiler.dart' show Compiler;
+import '../compiler_interfaces.dart' show CompilerDeferredLoadingFacade;
 import '../constants/values.dart';
-import '../elements/types.dart';
 import '../elements/entities.dart';
-import '../kernel/element_map.dart';
-import '../kernel/kernel_world.dart';
+import '../elements/types.dart';
+import '../kernel/element_map_interfaces.dart'
+    show KernelToElementMapForDeferredLoading;
+import '../kernel/kernel_world_interfaces.dart' show KClosedWorld;
 import '../util/util.dart' show makeUnique;
 
+// TODO(48820): delete typedef after the migration is complete.
+typedef Compiler = CompilerDeferredLoadingFacade;
+typedef KernelToElementMap = KernelToElementMapForDeferredLoading;
+
 class _DeferredLoadTaskMetrics implements Metrics {
   @override
   String get namespace => 'deferred_load';
@@ -313,7 +316,7 @@
   String get name => 'Deferred Loading';
 
   /// The OutputUnit that will be loaded when the program starts.
-  /*late final*/ OutputUnit _mainOutputUnit;
+  final OutputUnit _mainOutputUnit;
 
   /// A sentinel used only by the [ImportSet] corresponding to the
   /// [_mainOutputUnit].
@@ -339,7 +342,10 @@
   final Map<ImportEntity, ImportDescription> _deferredImportDescriptions = {};
 
   /// A lattice to compactly represent multiple subsets of imports.
-  ImportSetLattice importSets = ImportSetLattice();
+  ///
+  /// This property is nullable only to reclaim memory after this phase is
+  /// complete.
+  ImportSetLattice? importSets = ImportSetLattice();
 
   final Compiler compiler;
 
@@ -350,10 +356,11 @@
 
   bool get disableProgramSplit => compiler.options.disableProgramSplit;
 
-  AlgorithmState algorithmState;
+  AlgorithmState? algorithmState;
 
-  DeferredLoadTask(this.compiler, this._elementMap) : super(compiler.measurer) {
-    _mainOutputUnit = OutputUnit(true, 'main', {});
+  DeferredLoadTask(this.compiler, this._elementMap)
+      : _mainOutputUnit = OutputUnit(true, 'main', {}),
+        super(compiler.measurer) {
     _allOutputUnits.add(_mainOutputUnit);
   }
 
@@ -384,7 +391,7 @@
 
     // Generate an output unit for all import sets that are associated with an
     // element or constant.
-    algorithmState?.entityToSet?.values?.forEach(addUnit);
+    algorithmState?.entityToSet.values.forEach(addUnit);
 
     // Sort output units to make the output of the compiler more stable.
     _allOutputUnits.sort();
@@ -403,7 +410,6 @@
     Set<String> usedImportNames = {};
     for (ImportEntity import in allDeferredImports) {
       String result = computeImportDeferName(import, compiler);
-      assert(result != null);
       if (useIds) {
         importDeferName[import] = (++nextDeferId).toString();
       } else {
@@ -418,13 +424,12 @@
   /// Returns a name for a deferred import.
   String computeImportDeferName(ImportEntity declaration, Compiler compiler) {
     assert(declaration.isDeferred);
-    if (declaration.name != null) {
-      return declaration.name;
-    } else {
-      // This happens when the deferred import isn't declared with a prefix.
-      assert(compiler.compilationFailed);
-      return '';
-    }
+    final name = declaration.name;
+    if (name != null) return name;
+
+    // This happens when the deferred import isn't declared with a prefix.
+    assert(compiler.compilationFailed);
+    return '';
   }
 
   /// Performs the deferred loading algorithm.
@@ -435,13 +440,13 @@
   }
 
   OutputUnitData _run(FunctionEntity main, KClosedWorld closedWorld) {
-    if (!isProgramSplit || main == null || disableProgramSplit) {
+    if (!isProgramSplit || disableProgramSplit) {
       return _buildResult();
     }
 
     work() {
       algorithmState = AlgorithmState.create(
-          main, compiler, _elementMap, closedWorld, importSets);
+          main, compiler, _elementMap, closedWorld, importSets!);
     }
 
     reporter.withCurrentElement(main.library, () => measure(work));
@@ -451,7 +456,7 @@
   // Dumps a graph as a list of strings of 0 and 1. There is one 'bit' for each
   // import entity in the graph, and each string in the list represents an
   // output unit.
-  void _dumpDeferredGraph() {
+  void _dumpDeferredGraph(Uri deferredGraphUri) {
     int id = 0;
     Map<ImportEntity, int> importMap = {};
     var entities = _deferredImportDescriptions.keys.toList();
@@ -465,13 +470,13 @@
       if (!outputUnit.isMainOutput) {
         List<int> representation = List.filled(id, 0);
         for (var entity in outputUnit.imports) {
-          representation[importMap[entity]] = 1;
+          representation[importMap[entity]!] = 1;
         }
         graph.add(representation.join());
       }
     }
-    compiler.outputProvider.createOutputSink(
-        compiler.options.deferredGraphUri.path, '', api.OutputType.debug)
+    compiler.outputProvider
+        .createOutputSink(deferredGraphUri.path, '', api.OutputType.debug)
       ..add(graph.join('\n'))
       ..close();
   }
@@ -479,25 +484,26 @@
   OutputUnitData _buildResult() {
     _createOutputUnits();
     _setupImportNames();
-    if (compiler.options.deferredGraphUri != null) {
-      _dumpDeferredGraph();
+    var deferredGraphUri = compiler.options.deferredGraphUri;
+    if (deferredGraphUri != null) {
+      _dumpDeferredGraph(deferredGraphUri);
     }
     Map<ClassEntity, OutputUnit> classMap = {};
     Map<ClassEntity, OutputUnit> classTypeMap = {};
     Map<MemberEntity, OutputUnit> memberMap = {};
     Map<Local, OutputUnit> localFunctionMap = {};
     Map<ConstantValue, OutputUnit> constantMap = {};
-    algorithmState?.entityToSet?.forEach((d, s) {
+    algorithmState?.entityToSet.forEach((d, s) {
       if (d is ClassEntityData) {
-        classMap[d.entity] = s.unit;
+        classMap[d.entity] = s.unit!;
       } else if (d is ClassTypeEntityData) {
-        classTypeMap[d.entity] = s.unit;
+        classTypeMap[d.entity] = s.unit!;
       } else if (d is MemberEntityData) {
-        memberMap[d.entity] = s.unit;
+        memberMap[d.entity] = s.unit!;
       } else if (d is LocalFunctionEntityData) {
-        localFunctionMap[d.entity] = s.unit;
+        localFunctionMap[d.entity] = s.unit!;
       } else if (d is ConstantEntityData) {
-        constantMap[d.entity] = s.unit;
+        constantMap[d.entity] = s.unit!;
       } else {
         throw 'Unrecognized EntityData $d';
       }
@@ -520,7 +526,7 @@
   void beforeResolution(Uri rootLibraryUri, Iterable<Uri> libraries) {
     measureSubtask('prepare', () {
       for (Uri uri in libraries) {
-        LibraryEntity library = elementEnvironment.lookupLibrary(uri);
+        LibraryEntity library = elementEnvironment.lookupLibrary(uri)!;
         reporter.withCurrentElement(library, () {
           for (ImportEntity import in elementEnvironment.getImports(library)) {
             if (import.isDeferred) {
@@ -532,17 +538,19 @@
         });
       }
 
+      final importSetsLattice = importSets!;
+
       // If program split constraints are provided, then parse and interpret
       // them now.
       if (compiler.programSplitConstraintsData != null) {
-        var builder = psc.Builder(compiler.programSplitConstraintsData);
+        var builder = psc.Builder(compiler.programSplitConstraintsData!);
         var transitions = builder.build(_allDeferredImports);
-        importSets.buildInitialSets(transitions.singletonTransitions);
-        importSets.buildSetTransitions(transitions.setTransitions);
+        importSetsLattice.buildInitialSets(transitions.singletonTransitions);
+        importSetsLattice.buildSetTransitions(transitions.setTransitions);
       }
 
       // Build the [ImportSet] representing the [_mainOutputUnit].
-      importSets.buildMainSet(
+      importSetsLattice.buildMainSet(
           _mainImport, _mainOutputUnit, _allDeferredImports);
     });
   }
@@ -551,22 +559,24 @@
   String dump() {
     Map<OutputUnit, List<String>> elementMap = {};
     Map<OutputUnit, List<String>> constantMap = {};
-    algorithmState?.entityToSet?.forEach((d, importSet) {
+    algorithmState?.entityToSet.forEach((d, importSet) {
       if (d is ClassEntityData) {
         var element = d.entity;
-        var elements = elementMap.putIfAbsent(importSet.unit, () => <String>[]);
-        var id = element.name ?? '$element';
+        var elements =
+            elementMap.putIfAbsent(importSet.unit!, () => <String>[]);
+        var id = element.name;
         id = '$id cls';
         elements.add(id);
       } else if (d is ClassTypeEntityData) {
         var element = d.entity;
-        var elements = elementMap.putIfAbsent(importSet.unit, () => <String>[]);
-        var id = element.name ?? '$element';
+        var elements =
+            elementMap.putIfAbsent(importSet.unit!, () => <String>[]);
+        var id = element.name;
         id = '$id type';
         elements.add(id);
       } else if (d is MemberEntityData) {
         var element = d.entity;
-        var elements = elementMap.putIfAbsent(importSet.unit, () => []);
+        var elements = elementMap.putIfAbsent(importSet.unit!, () => []);
         var id = element.name ?? '$element';
         var cls = element.enclosingClass?.name;
         if (cls != null) id = '$cls.$id';
@@ -575,7 +585,7 @@
         elements.add(id);
       } else if (d is LocalFunctionEntityData) {
         var element = d.entity;
-        var elements = elementMap.putIfAbsent(importSet.unit, () => []);
+        var elements = elementMap.putIfAbsent(importSet.unit!, () => []);
         var id = element.name ?? '$element';
         var context = (element as dynamic).memberContext.name;
         id = element.name == null || element.name == '' ? '<anonymous>' : id;
@@ -588,7 +598,7 @@
         // if they are shared, they end up duplicated anyways across output units.
         if (value is PrimitiveConstantValue) return;
         constantMap
-            .putIfAbsent(importSet.unit, () => [])
+            .putIfAbsent(importSet.unit!, () => [])
             .add(value.toStructuredText(dartTypes));
       } else {
         throw 'Unrecognized EntityData $d';
@@ -609,14 +619,14 @@
           unitText.write('\n   $i:');
         }
       }
-      List<String> elements = elementMap[outputUnit];
+      List<String>? elements = elementMap[outputUnit];
       if (elements != null) {
         unitText.write('\n elements:');
         for (String element in elements..sort()) {
           unitText.write('\n  $element');
         }
       }
-      List<String> constants = constantMap[outputUnit];
+      List<String>? constants = constantMap[outputUnit];
       if (constants != null) {
         unitText.write('\n constants:');
         for (String value in constants..sort()) {
@@ -628,7 +638,7 @@
 
     StringBuffer sb = StringBuffer();
     for (OutputUnit outputUnit in _allOutputUnits.toList()
-      ..sort((a, b) => text[a].compareTo(text[b]))) {
+      ..sort((a, b) => text[a]!.compareTo(text[b]!))) {
       sb.write('\n\n-------------------------------\n');
       sb.write('Output unit: ${outputUnit.name}');
       sb.write('\n ${text[outputUnit]}');
diff --git a/pkg/compiler/lib/src/deferred_load/entity_data_info.dart b/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
index 064a126..81630f2 100644
--- a/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
+++ b/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
@@ -2,8 +2,6 @@
 // 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.
 
-// @dart = 2.10
-
 import 'package:kernel/ast.dart' as ir;
 import 'package:kernel/type_environment.dart' as ir;
 
@@ -11,18 +9,23 @@
 
 import '../common.dart';
 import '../common/elements.dart' show CommonElements, KElementEnvironment;
-import '../compiler.dart' show Compiler;
+import '../compiler_interfaces.dart' show CompilerDeferredLoadingFacade;
 import '../constants/values.dart'
     show ConstantValue, ConstructedConstantValue, InstantiationConstantValue;
-import '../elements/types.dart';
 import '../elements/entities.dart';
+import '../elements/types.dart';
 import '../ir/util.dart';
+import '../kernel/element_map_interfaces.dart'
+    show KernelToElementMapForDeferredLoading;
 import '../kernel/kelements.dart' show KLocalFunction;
-import '../kernel/element_map.dart';
-import '../kernel/kernel_world.dart';
+import '../kernel/kernel_world_interfaces.dart' show KClosedWorld;
 import '../universe/use.dart';
 import '../universe/world_impact.dart' show WorldImpact;
 
+// TODO(48820): delete typedef after the migration is complete.
+typedef Compiler = CompilerDeferredLoadingFacade;
+typedef KernelToElementMap = KernelToElementMapForDeferredLoading;
+
 /// [EntityDataInfo] is meta data about [EntityData] for a given compilation
 /// [Entity].
 class EntityDataInfo {
@@ -33,7 +36,7 @@
   final Set<EntityData> directDependencies = {};
 
   /// Various [add] methods for various types of direct dependencies.
-  void add(EntityData entityData, {ImportEntity import}) {
+  void add(EntityData entityData, {ImportEntity? import}) {
     // If we already have a direct dependency on [entityData] then we have
     // nothing left to do.
     if (directDependencies.contains(entityData)) return;
@@ -67,11 +70,11 @@
       compiler.frontendStrategy.elementEnvironment;
   CommonElements get commonElements => compiler.frontendStrategy.commonElements;
 
-  void add(EntityData data, {ImportEntity import}) {
+  void add(EntityData data, {ImportEntity? import}) {
     info.add(data, import: import);
   }
 
-  void addClass(ClassEntity cls, {ImportEntity import}) {
+  void addClass(ClassEntity cls, {ImportEntity? import}) {
     add(registry.createClassEntityData(cls), import: import);
 
     // Add a classType entityData as well just in case we optimize out
@@ -79,15 +82,15 @@
     addClassType(cls, import: import);
   }
 
-  void addClassType(ClassEntity cls, {ImportEntity import}) {
+  void addClassType(ClassEntity cls, {ImportEntity? import}) {
     add(registry.createClassTypeEntityData(cls), import: import);
   }
 
-  void addMember(MemberEntity m, {ImportEntity import}) {
+  void addMember(MemberEntity m, {ImportEntity? import}) {
     add(registry.createMemberEntityData(m), import: import);
   }
 
-  void addConstant(ConstantValue c, {ImportEntity import}) {
+  void addConstant(ConstantValue c, {ImportEntity? import}) {
     add(registry.createConstantEntityData(c), import: import);
   }
 
@@ -96,15 +99,15 @@
   }
 
   /// Recursively collects all the dependencies of [type].
-  void addTypeDependencies(DartType type, [ImportEntity import]) {
+  void addTypeDependencies(DartType type, [ImportEntity? import]) {
     TypeEntityDataVisitor(this, import, commonElements).visit(type);
   }
 
   /// Recursively collects all the dependencies of [types].
-  void addTypeListDependencies(Iterable<DartType> types,
-      [ImportEntity import]) {
+  void addTypeListDependencies(Iterable<DartType>? types,
+      [ImportEntity? import]) {
     if (types == null) return;
-    TypeEntityDataVisitor(this, import, commonElements).visitList(types);
+    TypeEntityDataVisitor(this, import, commonElements).visitIterable(types);
   }
 
   /// Collects all direct dependencies of [element].
@@ -121,7 +124,7 @@
     ConstantCollector.collect(elementMap, element, this);
   }
 
-  void _addFromStaticUse(MemberEntity parent, StaticUse staticUse) {
+  void _addFromStaticUse(MemberEntity? parent, StaticUse staticUse) {
     void processEntity() {
       Entity usedEntity = staticUse.element;
       if (usedEntity is MemberEntity) {
@@ -129,7 +132,7 @@
       } else {
         assert(usedEntity is KLocalFunction,
             failedAt(usedEntity, "Unexpected static use $staticUse."));
-        KLocalFunction localFunction = usedEntity;
+        var localFunction = usedEntity as KLocalFunction;
         // TODO(sra): Consult KClosedWorld to see if signature is needed.
         addTypeDependencies(localFunction.functionType);
         addLocalFunction(localFunction);
@@ -146,7 +149,7 @@
         // the target type is not relevant.
         // TODO(johnniwinther): Use rti need data to skip unneeded type
         // arguments.
-        addTypeListDependencies(staticUse.type.typeArguments);
+        addTypeListDependencies(staticUse.type!.typeArguments);
         processEntity();
         break;
       case StaticUseKind.STATIC_INVOKE:
@@ -176,13 +179,12 @@
         break;
       case StaticUseKind.CALL_METHOD:
       case StaticUseKind.INLINING:
-        failedAt(parent, "Unexpected static use: $staticUse.");
-        break;
+        failedAt(parent!, "Unexpected static use: $staticUse.");
     }
   }
 
-  void _addFromTypeUse(MemberEntity parent, TypeUse typeUse) {
-    void addClassIfInterfaceType(DartType t, [ImportEntity import]) {
+  void _addFromTypeUse(MemberEntity? parent, TypeUse typeUse) {
+    void addClassIfInterfaceType(DartType t, [ImportEntity? import]) {
       var typeWithoutNullability = t.withoutNullability;
       if (typeWithoutNullability is InterfaceType) {
         addClass(typeWithoutNullability.element, import: import);
@@ -233,14 +235,13 @@
       case TypeUseKind.TYPE_ARGUMENT:
       case TypeUseKind.NAMED_TYPE_VARIABLE_NEW_RTI:
       case TypeUseKind.CONSTRUCTOR_REFERENCE:
-        failedAt(parent, "Unexpected type use: $typeUse.");
-        break;
+        failedAt(parent!, "Unexpected type use: $typeUse.");
     }
   }
 
   /// Extract any dependencies that are known from the impact of [element].
   void _addDependenciesFromImpact(MemberEntity element) {
-    WorldImpact worldImpact = impactCache[element];
+    WorldImpact worldImpact = impactCache[element]!;
     worldImpact.forEachStaticUse(_addFromStaticUse);
     worldImpact.forEachTypeUse(_addFromTypeUse);
 
@@ -350,7 +351,7 @@
 
 class TypeEntityDataVisitor implements DartTypeVisitor<void, Null> {
   final EntityDataInfoBuilder _infoBuilder;
-  final ImportEntity _import;
+  final ImportEntity? _import;
   final CommonElements _commonElements;
 
   TypeEntityDataVisitor(this._infoBuilder, this._import, this._commonElements);
@@ -360,7 +361,7 @@
     type.accept(this, null);
   }
 
-  void visitList(List<DartType> types) {
+  void visitIterable(Iterable<DartType> types) {
     types.forEach(visit);
   }
 
@@ -402,7 +403,7 @@
 
   @override
   void visitInterfaceType(InterfaceType type, Null argument) {
-    visitList(type.typeArguments);
+    visitIterable(type.typeArguments);
     _infoBuilder.addClassType(type.element, import: _import);
   }
 
@@ -411,9 +412,9 @@
     for (FunctionTypeVariable typeVariable in type.typeVariables) {
       visit(typeVariable.bound);
     }
-    visitList(type.parameterTypes);
-    visitList(type.optionalParameterTypes);
-    visitList(type.namedParameterTypes);
+    visitIterable(type.parameterTypes);
+    visitIterable(type.optionalParameterTypes);
+    visitIterable(type.namedParameterTypes);
     visit(type.returnType);
   }
 
@@ -463,9 +464,10 @@
     node.function?.accept(visitor);
   }
 
-  void add(ir.Expression node, {bool required = true}) {
-    ConstantValue constant = elementMap
-        .getConstantValue(staticTypeContext, node, requireConstant: required);
+  void add(ir.Expression node, {bool requireConstant = true}) {
+    ConstantValue? constant = elementMap.getConstantValue(
+        staticTypeContext, node,
+        requireConstant: requireConstant);
     if (constant != null) {
       infoBuilder.addConstant(constant,
           import: elementMap.getImport(getDeferredImport(node)));
@@ -549,7 +551,7 @@
   void visitInstantiation(ir.Instantiation node) {
     // TODO(johnniwinther): The CFE should mark constant instantiations as
     // constant.
-    add(node, required: false);
+    add(node, requireConstant: false);
     super.visitInstantiation(node);
   }
 
diff --git a/pkg/compiler/lib/src/deferred_load/work_queue.dart b/pkg/compiler/lib/src/deferred_load/work_queue.dart
index f75174b..72708f9 100644
--- a/pkg/compiler/lib/src/deferred_load/work_queue.dart
+++ b/pkg/compiler/lib/src/deferred_load/work_queue.dart
@@ -2,8 +2,6 @@
 // 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.
 
-// @dart = 2.10
-
 import 'dart:collection' show Queue;
 
 import 'algorithm_state.dart';
diff --git a/pkg/compiler/lib/src/diagnostics/compiler_diagnostics_facade.dart b/pkg/compiler/lib/src/diagnostics/compiler_diagnostics_facade.dart
deleted file mode 100644
index 7dcbc76..0000000
--- a/pkg/compiler/lib/src/diagnostics/compiler_diagnostics_facade.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
-// 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.
-
-library dart2js.compiler_diagnostics_facade;
-
-import '../../compiler_api.dart' as api show Diagnostic;
-import '../elements/entities.dart' show Entity;
-import '../options.dart' show CompilerOptions;
-
-import 'diagnostic_listener.dart' show DiagnosticMessage;
-import 'source_span.dart';
-import 'spannable.dart';
-
-/// This interface is a subset of the [Compiler] methods that are needed by
-/// [DiagnosticListener].
-///
-/// See definitions on [Compiler] for documentation.
-// TODO(48820): Remove after compiler.dart is migrated.
-abstract class CompilerDiagnosticsFacade {
-  CompilerOptions get options;
-
-  bool inUserCode(Entity element);
-
-  Uri getCanonicalUri(Entity element);
-
-  void reportDiagnostic(DiagnosticMessage message,
-      List<DiagnosticMessage> infos, api.Diagnostic kind);
-
-  void fatalDiagnosticReported(DiagnosticMessage message,
-      List<DiagnosticMessage> infos, api.Diagnostic kind);
-
-  bool get compilationFailed;
-
-  SourceSpan spanFromSpannable(Spannable spannable, Entity? currentElement);
-}
diff --git a/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart b/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart
index 3ccca48..d022b36 100644
--- a/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart
+++ b/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart
@@ -5,7 +5,7 @@
 library dart2js.diagnostic_listener;
 
 import '../../compiler_api.dart' as api;
-import 'compiler_diagnostics_facade.dart';
+import '../compiler_interfaces.dart' show CompilerDiagnosticsFacade;
 import '../elements/entities.dart';
 import '../options.dart';
 import 'messages.dart';
diff --git a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
index 790e988..387d480 100644
--- a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
+++ b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
@@ -30,12 +30,14 @@
 import 'metadata_collector.dart' show MetadataCollector;
 import 'model.dart';
 import 'native_emitter.dart' show NativeEmitter;
+import 'interfaces.dart' as interfaces;
 
 /// Generates the code for all used classes in the program. Static fields (even
 /// in classes) are ignored, since they can be treated as non-class elements.
 ///
 /// The code for the containing (used) methods must exist in the `universe`.
-class CodeEmitterTask extends CompilerTask {
+class CodeEmitterTask extends CompilerTask
+    implements interfaces.CodeEmitterTask {
   RuntimeTypesChecks _rtiChecks;
   NativeEmitter _nativeEmitter;
   MetadataCollector metadataCollector;
@@ -61,6 +63,7 @@
   CodeEmitterTask(this._compiler, this._generateSourceMap)
       : super(_compiler.measurer);
 
+  @override
   NativeEmitter get nativeEmitter {
     assert(
         _nativeEmitter != null,
diff --git a/pkg/compiler/lib/src/js_emitter/interfaces.dart b/pkg/compiler/lib/src/js_emitter/interfaces.dart
new file mode 100644
index 0000000..46fdeb2
--- /dev/null
+++ b/pkg/compiler/lib/src/js_emitter/interfaces.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+/// Facades for pieces of the js_emitter used from other parts of the compiler.
+// TODO(48820): delete after the migration is complete.
+library compiler.src.js_emitter.interfaces;
+
+import '../elements/entities.dart';
+
+abstract class CodeEmitterTask {
+  NativeEmitter get nativeEmitter;
+}
+
+abstract class NativeEmitter {
+  Map<ClassEntity, List<ClassEntity>> get subtypes;
+  Map<ClassEntity, List<ClassEntity>> get directSubtypes;
+}
diff --git a/pkg/compiler/lib/src/js_emitter/native_emitter.dart b/pkg/compiler/lib/src/js_emitter/native_emitter.dart
index 40f80f5..cad3a65 100644
--- a/pkg/compiler/lib/src/js_emitter/native_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/native_emitter.dart
@@ -19,8 +19,9 @@
 
 import 'code_emitter_task.dart' show CodeEmitterTask;
 import 'model.dart';
+import 'interfaces.dart' as interfaces;
 
-class NativeEmitter {
+class NativeEmitter implements interfaces.NativeEmitter {
   final CodeEmitterTask _emitterTask;
   final JClosedWorld _closedWorld;
   final NativeCodegenEnqueuer _nativeCodegenEnqueuer;
@@ -29,8 +30,10 @@
   bool hasNativeClasses = false;
 
   // Caches the native subtypes of a native class.
+  @override
   Map<ClassEntity, List<ClassEntity>> subtypes = {};
 
+  @override
   // Caches the direct native subtypes of a native class.
   Map<ClassEntity, List<ClassEntity>> directSubtypes = {};
 
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 9198179..45f3683 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -61,7 +61,8 @@
         KernelElementEnvironment,
         KernelToElementMapForClassHierarchy,
         KernelToElementMapForImpactData,
-        KernelToElementMapForNativeData;
+        KernelToElementMapForNativeData,
+        KernelToElementMapForDeferredLoading;
 import 'env.dart';
 import 'kelements.dart';
 import 'kernel_impact.dart';
@@ -73,6 +74,7 @@
         interfaces.KernelToElementMapForClassHierarchy,
         interfaces.KernelToElementMapForImpactData,
         interfaces.KernelToElementMapForNativeData,
+        interfaces.KernelToElementMapForDeferredLoading,
         IrToElementMap {
   @override
   final CompilerOptions options;
@@ -839,6 +841,7 @@
   }
 
   /// Returns the defining node for [member].
+  @override
   ir.Member getMemberNode(covariant IndexedMember member) {
     assert(checkFamily(member));
     return members.getData(member).node;
@@ -851,6 +854,7 @@
   }
 
   /// Return the [ImportEntity] corresponding to [node].
+  @override
   ImportEntity getImport(ir.LibraryDependency node) {
     if (node == null) return null;
     ir.Library library = node.parent;
@@ -870,6 +874,7 @@
   ir.ClassHierarchy get classHierarchy =>
       _classHierarchy ??= ir.ClassHierarchy(env.mainComponent, coreTypes);
 
+  @override
   ir.StaticTypeContext getStaticTypeContext(MemberEntity member) {
     // TODO(johnniwinther): Cache the static type context.
     return ir.StaticTypeContext(getMemberNode(member), typeEnvironment);
@@ -1154,6 +1159,7 @@
   }
 
   /// Computes the [ConstantValue] for the constant [expression].
+  @override
   ConstantValue getConstantValue(
       ir.StaticTypeContext staticTypeContext, ir.Expression node,
       {bool requireConstant = true,
diff --git a/pkg/compiler/lib/src/kernel/element_map_interfaces.dart b/pkg/compiler/lib/src/kernel/element_map_interfaces.dart
index fa1ff53..ac78b1f 100644
--- a/pkg/compiler/lib/src/kernel/element_map_interfaces.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_interfaces.dart
@@ -7,12 +7,21 @@
 // element_map_impl.dart.
 
 import 'package:kernel/ast.dart' as ir
-    show Class, DartType, Field, Member, Procedure, ProcedureStubKind;
-
+    show
+        Class,
+        DartType,
+        Field,
+        Member,
+        Procedure,
+        ProcedureStubKind,
+        LibraryDependency,
+        Expression;
+import 'package:kernel/type_environment.dart' as ir show StaticTypeContext;
 import '../common.dart' show DiagnosticReporter;
 import '../common/elements.dart' show CommonElements, ElementEnvironment;
 import '../elements/entities.dart'
-    show ClassEntity, ConstructorEntity, MemberEntity;
+    show ClassEntity, ConstructorEntity, MemberEntity, ImportEntity;
+import '../constants/values.dart';
 import '../elements/indexed.dart' show IndexedClass;
 import '../elements/types.dart' show DartType, DartTypes, InterfaceType;
 import '../ir/constants.dart' show Dart2jsConstantEvaluator;
@@ -54,6 +63,18 @@
   DartType getDartType(ir.DartType type);
 }
 
+abstract class KernelToElementMapForDeferredLoading {
+  CommonElements get commonElements;
+  ConstantValue? getConstantValue(
+      ir.StaticTypeContext staticTypeContext, ir.Expression node,
+      {bool requireConstant = true,
+      bool implicitNull = false,
+      bool checkCasts = true});
+  ImportEntity getImport(ir.LibraryDependency? node);
+  ir.Member getMemberNode(MemberEntity member);
+  ir.StaticTypeContext getStaticTypeContext(MemberEntity member);
+}
+
 // Members which dart2js ignores.
 bool memberIsIgnorable(ir.Member node, {ir.Class? cls}) {
   if (node is! ir.Procedure) return false;
diff --git a/pkg/compiler/lib/src/kernel/kernel_strategy.dart b/pkg/compiler/lib/src/kernel/kernel_strategy.dart
index 922b7da..e53d7c6 100644
--- a/pkg/compiler/lib/src/kernel/kernel_strategy.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_strategy.dart
@@ -51,7 +51,10 @@
 
 /// Front end strategy that loads '.dill' files and builds a resolved element
 /// model from kernel IR nodes.
-class KernelFrontendStrategy implements KernelFrontendStrategyForBackendUsage {
+class KernelFrontendStrategy
+    implements
+        KernelFrontendStrategyForBackendUsage,
+        KernelFrontendStrategyForDeferredLoading {
   final CompilerOptions _options;
   final CompilerTask _compilerTask;
   /*late*/ KernelToElementMap _elementMap;
@@ -245,6 +248,7 @@
 
   /// Returns the [ElementEnvironment] for the element model used in this
   /// strategy.
+  @override
   KernelElementEnvironment get elementEnvironment =>
       _elementMap.elementEnvironment;
 
diff --git a/pkg/compiler/lib/src/kernel/kernel_strategy_migrated.dart b/pkg/compiler/lib/src/kernel/kernel_strategy_migrated.dart
index 25dfcf4..7e60149 100644
--- a/pkg/compiler/lib/src/kernel/kernel_strategy_migrated.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_strategy_migrated.dart
@@ -7,11 +7,17 @@
 library dart2js.kernel.frontend_strategy.facades;
 
 import '../common.dart' show SourceSpan, Spannable;
-import '../common/elements.dart' show KCommonElements;
+import '../common/elements.dart' show KCommonElements, KElementEnvironment;
 import '../elements/entities.dart' show Entity;
 
-/// Facade interface for KernelFrontendStrategy.
+/// Facade interface used by backend usage.
 abstract class KernelFrontendStrategyForBackendUsage {
   KCommonElements get commonElements;
   SourceSpan spanFromSpannable(Spannable spannable, Entity currentElement);
 }
+
+/// Facade interface used by deferred loading.
+abstract class KernelFrontendStrategyForDeferredLoading {
+  KCommonElements get commonElements;
+  KElementEnvironment get elementEnvironment;
+}
diff --git a/pkg/compiler/lib/src/native/enqueue.dart b/pkg/compiler/lib/src/native/enqueue.dart
index f50379f..7b6f737 100644
--- a/pkg/compiler/lib/src/native/enqueue.dart
+++ b/pkg/compiler/lib/src/native/enqueue.dart
@@ -2,13 +2,11 @@
 // 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.
 
-// @dart = 2.10
-
 import '../common/elements.dart' show CommonElements, ElementEnvironment;
 import '../elements/entities.dart';
 import '../elements/types.dart';
 import '../js_backend/native_data.dart' show NativeData;
-import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter;
+import '../js_emitter/interfaces.dart' show CodeEmitterTask, NativeEmitter;
 import '../options.dart';
 import '../universe/use.dart' show TypeUse;
 import '../universe/world_impact.dart'
@@ -24,7 +22,7 @@
   bool get hasInstantiatedNativeClasses => !_registeredClasses.isEmpty;
 
   /// Log message reported if all native types are used.
-  String _allUsedMessage;
+  String? _allUsedMessage;
 
   final CompilerOptions _options;
   final ElementEnvironment _elementEnvironment;
@@ -156,7 +154,7 @@
   /// Emits a summary information using the [log] function.
   void logSummary(void log(String message)) {
     if (_allUsedMessage != null) {
-      log(_allUsedMessage);
+      log(_allUsedMessage!);
     }
   }
 }
@@ -205,7 +203,7 @@
 
 class NativeCodegenEnqueuer extends NativeEnqueuer {
   final CodeEmitterTask _emitter;
-  final Iterable<ClassEntity> _nativeClasses;
+  final Set<ClassEntity> _nativeClasses;
   final NativeData _nativeData;
 
   final Set<ClassEntity> _doneAddSubtypes = {};
@@ -262,7 +260,11 @@
 
     // Walk the superclass chain since classes on the superclass chain might not
     // be instantiated (abstract or simply unused).
-    _addSubtypes(_elementEnvironment.getSuperClass(cls), emitter);
+    // Note: here and below we expect the superclass always to be non-null
+    // because we always start from a native class, which at least has Object as
+    // a superclass.
+    ClassEntity superclass = _elementEnvironment.getSuperClass(cls)!;
+    _addSubtypes(superclass, emitter);
 
     _elementEnvironment.forEachSupertype(cls, (InterfaceType type) {
       List<ClassEntity> subtypes =
@@ -273,11 +275,9 @@
     // Skip through all the mixin applications in the super class
     // chain. That way, the direct subtypes set only contain the
     // natives classes.
-    ClassEntity superclass = _elementEnvironment.getSuperClass(cls);
-    while (superclass != null &&
-        _elementEnvironment.isMixinApplication(superclass)) {
+    while (_elementEnvironment.isMixinApplication(superclass)) {
       assert(!_nativeData.isNativeClass(superclass));
-      superclass = _elementEnvironment.getSuperClass(superclass);
+      superclass = _elementEnvironment.getSuperClass(superclass)!;
     }
 
     List<ClassEntity> directSubtypes =
diff --git a/pkg/dart2wasm/lib/code_generator.dart b/pkg/dart2wasm/lib/code_generator.dart
index 0120221..fb2ac5f 100644
--- a/pkg/dart2wasm/lib/code_generator.dart
+++ b/pkg/dart2wasm/lib/code_generator.dart
@@ -890,6 +890,12 @@
 
   @override
   void visitSwitchStatement(SwitchStatement node) {
+    // If we have an empty switch, just evaluate the expression for any
+    // potential side effects. In this case, the return type does not matter.
+    if (node.cases.isEmpty) {
+      wrap(node.expression, voidMarker);
+      return;
+    }
     bool check<L extends Expression, C extends Constant>() =>
         node.cases.expand((c) => c.expressions).every((e) =>
             e is L ||
diff --git a/sdk/lib/_internal/wasm/lib/errors_patch.dart b/sdk/lib/_internal/wasm/lib/errors_patch.dart
index 666f279..88b9a22 100644
--- a/sdk/lib/_internal/wasm/lib/errors_patch.dart
+++ b/sdk/lib/_internal/wasm/lib/errors_patch.dart
@@ -73,3 +73,16 @@
     return _throwObjectWithStackTrace(typeError, stackTrace);
   }
 }
+
+/// Used by Fasta to report a runtime error when a final field with an
+/// initializer is also initialized in a generative constructor.
+///
+/// Note: In strong mode, this is a compile-time error, but the CFE still needs
+/// this class to exist in `dart:core`.
+class _DuplicatedFieldInitializerError extends Error {
+  final String _name;
+
+  _DuplicatedFieldInitializerError(this._name);
+
+  toString() => "Error: field '$_name' is already initialized.";
+}
diff --git a/sdk/lib/_internal/wasm/lib/string_patch.dart b/sdk/lib/_internal/wasm/lib/string_patch.dart
index 5eb2461..5b09baa 100644
--- a/sdk/lib/_internal/wasm/lib/string_patch.dart
+++ b/sdk/lib/_internal/wasm/lib/string_patch.dart
@@ -169,9 +169,11 @@
     if (charCodes is EfficientLengthIterable) {
       int length = charCodes.length;
       final endVal = RangeError.checkValidRange(start, end, length);
-      final charCodeList = new List<int>.from(
-          charCodes.take(endVal).skip(start),
-          growable: false);
+      final Uint16List charCodeList = Uint16List(endVal - start);
+      int i = 0;
+      for (final char in charCodes.take(endVal).skip(start)) {
+        charCodeList[i++] = char;
+      }
       return createFromCharCodes(charCodeList, 0, charCodeList.length, null);
     }
     // Don't know length of iterable, so iterate and see if all the values
diff --git a/tools/VERSION b/tools/VERSION
index 9bb2099..ecc211e 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 19
 PATCH 0
-PRERELEASE 24
+PRERELEASE 25
 PRERELEASE_PATCH 0
\ No newline at end of file