Version 2.13.0-26.0.dev

Merge commit 'f358afca9e9fc51a16c549ccbd38c0de70e99f82' into 'dev'
diff --git a/DEPS b/DEPS
index 284573c..19a424f 100644
--- a/DEPS
+++ b/DEPS
@@ -102,7 +102,7 @@
 
   "chromedriver_tag": "83.0.4103.39",
   "dartdoc_rev" : "9e61a4f11091aaa8998525a2692b14148dc24ab5",
-  "ffi_rev": "53866b792f397113189bce3ea71e83b0e46b9cea",
+  "ffi_rev": "afb6b2c3a15c50e8f12ac15f368c7f1560f2d2f1",
   "fixnum_rev": "16d3890c6dc82ca629659da1934e412292508bba",
   "file_rev": "0e09370f581ab6388d46fda4cdab66638c0171a1",
   "glob_rev": "a62acf590598f458d3198d9f2930c1c9dd4b1379",
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index 1064785..e0c94c5 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,5 +1,5 @@
 name: _fe_analyzer_shared
-version: 15.0.0
+version: 16.0.0
 description: Logic that is shared between the front_end and analyzer packages.
 homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
 
diff --git a/pkg/analysis_server/benchmark/perf/memory_tests.dart b/pkg/analysis_server/benchmark/perf/memory_tests.dart
index 5806745..8f8a097 100644
--- a/pkg/analysis_server/benchmark/perf/memory_tests.dart
+++ b/pkg/analysis_server/benchmark/perf/memory_tests.dart
@@ -7,7 +7,6 @@
 import 'dart:io';
 
 import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
-import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analysis_server/src/lsp/handlers/handler_completion.dart';
 import 'package:analysis_server/src/protocol_server.dart';
 import 'package:analyzer/instrumentation/instrumentation.dart';
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index caf7177..d96b0c4 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -111,8 +111,6 @@
 
   final List<String> analyzableFilePatterns = <String>[
     '**/*.${AnalysisEngine.SUFFIX_DART}',
-    '**/*.${AnalysisEngine.SUFFIX_HTML}',
-    '**/*.${AnalysisEngine.SUFFIX_HTM}',
     '**/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}',
     '**/${AnalysisEngine.PUBSPEC_YAML_FILE}',
     '**/${AnalysisEngine.ANDROID_MANIFEST_FILE}'
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_diagnostic_property_reference.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_diagnostic_property_reference.dart
index af47d5d..ec78b1d 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_diagnostic_property_reference.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_diagnostic_property_reference.dart
@@ -46,7 +46,7 @@
     List<DartType> typeArgs;
     var constructorName = '';
 
-    if (type.element is FunctionTypedElement) {
+    if (type is FunctionType) {
       constructorId = 'ObjectFlagProperty';
       typeArgs = [type];
       constructorName = '.has';
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_method_or_function.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_method_or_function.dart
index c92e700..166d447 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_method_or_function.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_method_or_function.dart
@@ -36,8 +36,8 @@
         var target = getQualifiedPropertyTarget(node);
         if (target != null) {
           var targetType = target.staticType;
-          if (targetType != null && targetType.element is ClassElement) {
-            targetElement = targetType.element as ClassElement;
+          if (targetType is InterfaceType) {
+            targetElement = targetType.element;
             argument = target.parent as Expression;
           } else {
             return;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/code_template.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/code_template.dart
index c7345c3..4fc44c5 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/code_template.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/code_template.dart
@@ -102,6 +102,10 @@
         return parent.parent.parent.parent;
       } else if (parent is MethodInvocation && parent.methodName == node) {
         return parent;
+      } else if (parent is TypeName &&
+          parent.parent is ConstructorName &&
+          parent.parent.parent is InstanceCreationExpression) {
+        return parent.parent.parent;
       }
     } else if (node is TypeArgumentList) {
       var parent = node.parent;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/modify_parameters.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/modify_parameters.dart
index 3c49589..c472d13 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/modify_parameters.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/modify_parameters.dart
@@ -177,7 +177,9 @@
       }
       // The remaining insertion ranges might include new required arguments
       // that need to be inserted after the last argument.
-      var offset = arguments[arguments.length - 1].end;
+      var offset = arguments.isEmpty
+          ? argumentList.leftParenthesis.end
+          : arguments[arguments.length - 1].end;
       while (nextInsertionRange < insertionRanges.length) {
         var insertionRange = insertionRanges[nextInsertionRange];
         var lower = insertionRange.lower;
@@ -220,6 +222,12 @@
     } else if (parent?.parent is InvocationExpression) {
       var argumentList = (parent.parent as InvocationExpression).argumentList;
       return _Data(argumentList);
+    } else if (parent is TypeName &&
+        parent.parent is ConstructorName &&
+        parent.parent.parent is InstanceCreationExpression) {
+      var argumentList =
+          (parent.parent.parent as InstanceCreationExpression).argumentList;
+      return _Data(argumentList);
     }
     return null;
   }
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_override_set_parser.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_override_set_parser.dart
index fea46f7..58abf49 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_override_set_parser.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_override_set_parser.dart
@@ -8,8 +8,6 @@
 import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_parser.dart';
 import 'package:analysis_server/src/utilities/extensions/yaml.dart';
 import 'package:analyzer/error/listener.dart';
-import 'package:yaml/src/yaml_exception.dart';
-import 'package:yaml/src/yaml_node.dart';
 import 'package:yaml/yaml.dart';
 
 /// A parser used to parse the content of a configuration file.
diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
index 1dd7834..73c0cf4 100644
--- a/pkg/analysis_server/test/context_manager_test.dart
+++ b/pkg/analysis_server/test/context_manager_test.dart
@@ -1551,8 +1551,6 @@
   List<Glob> get analysisFilesGlobs {
     var patterns = <String>[
       '**/*.${AnalysisEngine.SUFFIX_DART}',
-      '**/*.${AnalysisEngine.SUFFIX_HTML}',
-      '**/*.${AnalysisEngine.SUFFIX_HTM}',
       '**/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'
     ];
     return patterns
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart
index ee6c688..e8d6d1b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/flutter_use_case_test.dart
@@ -502,6 +502,113 @@
   }
 
   Future<void>
+      test_gestures_VelocityTracker_unnamedConstructor_withArg_deprecated() async {
+    setPackageContent('''
+class VelocityTracker {
+  @deprecated
+  VelocityTracker([PointerDeviceKind kind = PointerDeviceKind.touch]);
+  VelocityTracker.withKind(PointerDeviceKind kind);
+}
+class PointerDeviceKind {
+  static PointerDeviceKind mouse = PointerDeviceKind();
+  static PointerDeviceKind touch = PointerDeviceKind();
+}
+''');
+    addPackageDataFile('''
+version: 1
+transforms:
+  - title: "Use withKind"
+    date: 2020-09-17
+    element:
+      uris: ['$importUri']
+      constructor: ''
+      inClass: 'VelocityTracker'
+    oneOf:
+      - if: "pointerDeviceKind == ''"
+        changes:
+          - kind: 'rename'
+            newName: 'withKind'
+          - kind: 'addParameter'
+            index: 0
+            name: 'kind'
+            style: required_positional
+            argumentValue:
+              expression: 'PointerDeviceKind.touch'
+      - if: "pointerDeviceKind != ''"
+        changes:
+          - kind: 'rename'
+            newName: 'withKind'
+    variables:
+      pointerDeviceKind:
+        kind: 'fragment'
+        value: 'arguments[0]'
+''');
+    await resolveTestCode('''
+import '$importUri';
+
+VelocityTracker tracker = VelocityTracker(PointerDeviceKind.mouse);
+''');
+    await assertHasFix('''
+import '$importUri';
+
+VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.mouse);
+''');
+  }
+
+  Future<void>
+      test_gestures_VelocityTracker_unnamedConstructor_withoutArg_deprecated() async {
+    setPackageContent('''
+class VelocityTracker {
+  @deprecated
+  VelocityTracker([PointerDeviceKind kind = PointerDeviceKind.touch]);
+  VelocityTracker.withKind(PointerDeviceKind kind);
+}
+class PointerDeviceKind {
+  static PointerDeviceKind touch = PointerDeviceKind();
+}
+''');
+    addPackageDataFile('''
+version: 1
+transforms:
+  - title: "Use withKind"
+    date: 2020-09-17
+    element:
+      uris: ['$importUri']
+      constructor: ''
+      inClass: 'VelocityTracker'
+    oneOf:
+      - if: "pointerDeviceKind == ''"
+        changes:
+          - kind: 'rename'
+            newName: 'withKind'
+          - kind: 'addParameter'
+            index: 0
+            name: 'kind'
+            style: required_positional
+            argumentValue:
+              expression: 'PointerDeviceKind.touch'
+      - if: "pointerDeviceKind != ''"
+        changes:
+          - kind: 'rename'
+            newName: 'withKind'
+    variables:
+      pointerDeviceKind:
+        kind: 'fragment'
+        value: 'arguments[0]'
+''');
+    await resolveTestCode('''
+import '$importUri';
+
+VelocityTracker tracker = VelocityTracker();
+''');
+    await assertHasFix('''
+import '$importUri';
+
+VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);
+''');
+  }
+
+  Future<void>
       test_material_BottomNavigationBarItem_unnamedConstructor_deprecated() async {
     setPackageContent('''
 class BottomNavigationBarItem {
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 71d0aa1..875fc6a 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.0.0
+* Stable null safety release.
+* Updated dependencies to null safe releases.
+
 ## 0.42.0-nullsafety.0
 * Migrated to null safety, min SDK is `2.12.0`.
 * Deprecated `FunctionTypeAliasElement.function`.
@@ -10,6 +14,7 @@
 * Removed `functionTypeAliasElement` from `TypeSystem.instantiateToBounds2`.
 * Added `Annotation.typeArguments` in preparation for supporting #44838.
 * Removed `actualUri` from `UriResolver.resolveAbsolute`.
+* Deprecated `FunctionType.element` and `FunctionType.typeArguments`.
 
 ## 0.41.1
 * Updated `PackageBuildWorkspace` that supports `package:build` to stop
diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart
index 88d625a..e772019 100644
--- a/pkg/analyzer/lib/dart/element/type.dart
+++ b/pkg/analyzer/lib/dart/element/type.dart
@@ -195,6 +195,10 @@
 ///
 /// Clients may not extend, implement or mix-in this class.
 abstract class FunctionType implements ParameterizedType {
+  @Deprecated('Use aliasElement instead')
+  @override
+  FunctionTypedElement? get element;
+
   /// Return a map from the names of named parameters to the types of the named
   /// parameters of this type of function. The entries in the map will be
   /// iterated in the same order as the order in which the named parameters were
@@ -230,6 +234,10 @@
   /// Return the type of object returned by this type of function.
   DartType get returnType;
 
+  @Deprecated('Use aliasArguments instead')
+  @override
+  List<DartType> get typeArguments;
+
   /// The formal type parameters of this generic function.
   /// For example `<T> T -> T`.
   ///
@@ -240,7 +248,7 @@
   List<TypeParameterElement> get typeFormals;
 
   /// Produces a new function type by substituting type parameters of this
-  /// function type with the given [typeArguments]. The resulting function
+  /// function type with the given [argumentTypes]. The resulting function
   /// type will have no type parameters.
   FunctionType instantiate(List<DartType> argumentTypes);
 }
diff --git a/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart b/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
index a32a3dd..a9ad271 100644
--- a/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
@@ -68,10 +68,11 @@
   YamlMap getOptionsFromSource(Source source) {
     YamlMap options = getOptionsFromString(_readAnalysisOptions(source));
     var node = getValue(options, AnalyzerOptions.include);
+    var sourceFactory = this.sourceFactory;
     if (sourceFactory != null && node is YamlScalar) {
       var path = node.value;
       if (path is String) {
-        var parent = sourceFactory!.resolveUri(source, path);
+        var parent = sourceFactory.resolveUri(source, path);
         if (parent != null) {
           options = merge(getOptionsFromSource(parent), options);
         }
diff --git a/pkg/analyzer/lib/src/dart/ast/extensions.dart b/pkg/analyzer/lib/src/dart/ast/extensions.dart
index 2a92953..7451b12 100644
--- a/pkg/analyzer/lib/src/dart/ast/extensions.dart
+++ b/pkg/analyzer/lib/src/dart/ast/extensions.dart
@@ -76,6 +76,21 @@
   return null;
 }
 
+extension ExpressionExtension on Expression {
+  /// Return the static type of this expression.
+  ///
+  /// This accessor should be used on expressions that are expected to
+  /// be already resolved. Every such expression must have the type set,
+  /// at least `dynamic`.
+  DartType get typeOrThrow {
+    var type = staticType;
+    if (type == null) {
+      throw StateError('No type: $this');
+    }
+    return type;
+  }
+}
+
 extension FormalParameterExtension on FormalParameter {
   FormalParameter get notDefault {
     var self = this;
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index 9cc80b8..3f8499f 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -12,6 +12,7 @@
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/ast/utilities.dart';
 import 'package:analyzer/src/dart/constant/evaluation.dart';
 import 'package:analyzer/src/dart/constant/potentially_constant.dart';
@@ -38,9 +39,6 @@
   /// The set of variables declared using '-D' on the command line.
   final DeclaredVariables declaredVariables;
 
-  /// The type representing the type 'int'.
-  final InterfaceType _intType;
-
   /// The current library that is being analyzed.
   final LibraryElementImpl _currentLibrary;
 
@@ -67,8 +65,7 @@
     this._typeSystem,
     this._typeProvider,
     this.declaredVariables,
-  )   : _intType = _typeProvider.intType,
-        _evaluationEngine = ConstantEvaluationEngine(declaredVariables);
+  ) : _evaluationEngine = ConstantEvaluationEngine(declaredVariables);
 
   bool get _isNonNullableByDefault => _currentLibrary.isNonNullableByDefault;
 
@@ -287,16 +284,14 @@
   ///         not <i>int</i> or <i>String</i>.
   bool _implementsEqualsWhenNotAllowed(DartType? type) {
     // ignore int or String
-    if (type == null ||
-        type.element == _intType.element ||
-        type.element == _typeProvider.stringType.element) {
+    if (type == null || type.isDartCoreInt || type.isDartCoreString) {
       return false;
-    } else if (type.element == _typeProvider.doubleType.element) {
+    } else if (type.isDartCoreDouble) {
       return true;
     }
     // prepare ClassElement
-    var element = type.element;
-    if (element is ClassElement) {
+    if (type is InterfaceType) {
+      var element = type.element;
       // lookup for ==
       var method = element.lookUpConcreteMethod("==", _currentLibrary);
       if (method == null ||
@@ -579,7 +574,7 @@
   }
 
   void _validateSwitchStatement_nullSafety(SwitchStatement node) {
-    var switchType = node.expression.staticType!;
+    var switchType = node.expression.typeOrThrow;
     for (var switchMember in node.members) {
       if (switchMember is SwitchCase) {
         Expression expression = switchMember.expression;
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index c092d6e..5611186 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -119,6 +119,7 @@
         super(element,
             aliasElement: aliasElement, aliasArguments: aliasArguments);
 
+  @Deprecated('Use aliasElement instead')
   @override
   FunctionTypedElement? get element {
     // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
@@ -138,9 +139,6 @@
 
   @override
   int get hashCode {
-    if (element == null) {
-      return 0;
-    }
     // Reference the arrays of parameters
     List<DartType> normalParameterTypes = this.normalParameterTypes;
     List<DartType> optionalParameterTypes = this.optionalParameterTypes;
@@ -208,6 +206,7 @@
     return types;
   }
 
+  @Deprecated('Use aliasArguments instead')
   @override
   List<DartType> get typeArguments {
     // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart
index 3fa2aa1..086fa9c 100644
--- a/pkg/analyzer/lib/src/dart/element/type_system.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_system.dart
@@ -621,7 +621,7 @@
             appendParameters(type.returnType);
             type.parameters.map((p) => p.type).forEach(appendParameters);
             // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44218
-            type.typeArguments.forEach(appendParameters);
+            type.aliasArguments?.forEach(appendParameters);
           } else if (type is InterfaceType) {
             type.typeArguments.forEach(appendParameters);
           }
diff --git a/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart
index 88b4fd2..339901a 100644
--- a/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart
@@ -9,6 +9,7 @@
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/ast/token.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -89,7 +90,7 @@
     if (flow != null) {
       if (writeElement is PromotableElement) {
         flow.write(
-            node, writeElement, node.staticType!, hasRead ? null : right);
+            node, writeElement, node.typeOrThrow, hasRead ? null : right);
       }
       if (isIfNull) {
         flow.ifNullExpression_end();
@@ -197,7 +198,7 @@
 
     var operator = node.operator.type;
     if (operator == TokenType.EQ) {
-      assignedType = node.rightHandSide.staticType!;
+      assignedType = node.rightHandSide.typeOrThrow;
       nodeType = assignedType;
     } else if (operator == TokenType.QUESTION_QUESTION_EQ) {
       var leftType = node.readType!;
@@ -207,7 +208,7 @@
         leftType = _typeSystem.promoteToNonNull(leftType);
       }
 
-      assignedType = node.rightHandSide.staticType!;
+      assignedType = node.rightHandSide.typeOrThrow;
       nodeType = _typeSystem.getLeastUpperBound(leftType, assignedType);
     } else if (operator == TokenType.AMPERSAND_AMPERSAND_EQ ||
         operator == TokenType.BAR_BAR_EQ) {
@@ -217,7 +218,7 @@
       var operatorElement = node.staticElement;
       if (operatorElement != null) {
         var leftType = node.readType!;
-        var rightType = node.rightHandSide.staticType!;
+        var rightType = node.rightHandSide.typeOrThrow;
         assignedType = _typeSystem.refineBinaryExpressionType(
           leftType,
           operator,
@@ -278,14 +279,17 @@
   ErrorReporter get _errorReporter => _resolver.errorReporter;
 
   void checkFinalAlreadyAssigned(Expression left) {
-    var flow = _resolver.flowAnalysis?.flow;
-    if (flow != null && left is SimpleIdentifier) {
+    var flowAnalysis = _resolver.flowAnalysis;
+    if (flowAnalysis == null) return;
+
+    var flow = flowAnalysis.flow;
+    if (flow == null) return;
+
+    if (left is SimpleIdentifier) {
       var element = left.staticElement;
       if (element is PromotableElement) {
-        var assigned =
-            _resolver.flowAnalysis!.isDefinitelyAssigned(left, element);
-        var unassigned =
-            _resolver.flowAnalysis!.isDefinitelyUnassigned(left, element);
+        var assigned = flowAnalysis.isDefinitelyAssigned(left, element);
+        var unassigned = flowAnalysis.isDefinitelyUnassigned(left, element);
 
         if (element.isFinal) {
           if (element.isLate) {
diff --git a/pkg/analyzer/lib/src/dart/resolver/binary_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/binary_expression_resolver.dart
index 38fcc61..7565747 100644
--- a/pkg/analyzer/lib/src/dart/resolver/binary_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/binary_expression_resolver.dart
@@ -9,6 +9,7 @@
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/resolver/invocation_inference_helper.dart';
@@ -101,7 +102,7 @@
     var flow = _resolver.flowAnalysis?.flow;
     var leftExtensionOverride = left is ExtensionOverride;
     if (!leftExtensionOverride) {
-      flow?.equalityOp_rightBegin(left, left.staticType!);
+      flow?.equalityOp_rightBegin(left, left.typeOrThrow);
     }
 
     var right = node.rightOperand;
@@ -109,7 +110,7 @@
     right = node.rightOperand;
 
     if (!leftExtensionOverride) {
-      flow?.equalityOp_end(node, right, right.staticType!, notEqual: notEqual);
+      flow?.equalityOp_end(node, right, right.typeOrThrow, notEqual: notEqual);
     }
 
     _resolveUserDefinableElement(
@@ -133,7 +134,7 @@
 
     left.accept(_resolver);
     left = node.leftOperand;
-    var leftType = left.staticType!;
+    var leftType = left.typeOrThrow;
 
     var rightContextType = InferenceContext.getContext(node);
     if (rightContextType == null || rightContextType.isDynamic) {
@@ -146,7 +147,7 @@
     right = node.rightOperand;
     flow?.ifNullExpression_end();
 
-    var rightType = right.staticType!;
+    var rightType = right.typeOrThrow;
     if (_isNonNullableByDefault) {
       var promotedLeftType = _typeSystem.promoteToNonNull(leftType);
       _analyzeLeastUpperBoundTypes(node, promotedLeftType, rightType);
@@ -285,7 +286,7 @@
       return;
     }
 
-    var leftType = leftOperand.staticType!;
+    var leftType = leftOperand.typeOrThrow;
     leftType = _resolveTypeParameter(leftType);
 
     if (identical(leftType, NeverTypeImpl.instance)) {
@@ -334,7 +335,7 @@
     if (leftOperand is ExtensionOverride) {
       leftType = leftOperand.extendedType!;
     } else {
-      leftType = leftOperand.staticType!;
+      leftType = leftOperand.typeOrThrow;
       leftType = _resolveTypeParameter(leftType);
     }
 
@@ -349,7 +350,7 @@
       staticType = _typeSystem.refineBinaryExpressionType(
         leftType,
         node.operator.type,
-        node.rightOperand.staticType!,
+        node.rightOperand.typeOrThrow,
         staticType,
         node.staticElement,
       );
diff --git a/pkg/analyzer/lib/src/dart/resolver/body_inference_context.dart b/pkg/analyzer/lib/src/dart/resolver/body_inference_context.dart
index 05991d0..b9f8ce4 100644
--- a/pkg/analyzer/lib/src/dart/resolver/body_inference_context.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/body_inference_context.dart
@@ -6,6 +6,7 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/dart/element/type_provider.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 
@@ -56,7 +57,7 @@
     if (expression == null) {
       _returnTypes.add(_typeProvider.nullType);
     } else {
-      var type = expression.staticType!;
+      var type = expression.typeOrThrow;
       if (_isAsynchronous) {
         type = _typeSystem.flatten(type);
       }
@@ -65,7 +66,7 @@
   }
 
   void addYield(YieldStatement node) {
-    var expressionType = node.expression.staticType!;
+    var expressionType = node.expression.typeOrThrow;
 
     if (node.star == null) {
       _returnTypes.add(expressionType);
diff --git a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
index 126a6d7..89fbdad 100644
--- a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
@@ -10,6 +10,7 @@
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/generic_inferrer.dart';
 import 'package:analyzer/src/dart/element/member.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -141,7 +142,7 @@
     }
 
     var receiverExpression = arguments[0];
-    var receiverType = receiverExpression.staticType!;
+    var receiverType = receiverExpression.typeOrThrow;
 
     if (node.isNullAware) {
       receiverType = _typeSystem.promoteToNonNull(receiverType);
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
index 0215f6e..e825a4a 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_algebra.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -241,7 +242,7 @@
         targetType,
         node.methodName.staticElement,
         [
-          for (var argument in node.argumentList.arguments) argument.staticType!
+          for (var argument in node.argumentList.arguments) argument.typeOrThrow
         ],
         returnType,
       );
@@ -289,7 +290,7 @@
       ParameterElement? parameter = rawParameters[i];
       if (parameter != null) {
         params.add(parameter);
-        argTypes.add(argumentList.arguments[i].staticType!);
+        argTypes.add(argumentList.arguments[i].typeOrThrow);
       }
     }
     var typeArgs = _typeSystem.inferGenericFunctionOrType(
diff --git a/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart b/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart
index 77ca27a..94c39d7 100644
--- a/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart
@@ -144,6 +144,8 @@
       return;
     }
 
+    type.aliasArguments?.forEach(_assertLegacyType);
+
     if (type is TypeParameterType) {
       _assertLegacyType(type.bound);
     } else if (type is InterfaceType) {
@@ -151,7 +153,6 @@
     } else if (type is FunctionType) {
       _assertLegacyType(type.returnType);
       type.parameters.map((param) => param.type).forEach(_assertLegacyType);
-      type.typeArguments.forEach(_assertLegacyType);
       type.typeFormals.map((param) => param.bound).forEach(_assertLegacyType);
     }
 
diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
index 719f8d7..a975540 100644
--- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
@@ -8,6 +8,7 @@
 import 'package:analyzer/dart/element/scope.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/ast/utilities.dart';
 import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -135,7 +136,7 @@
       }
     }
 
-    DartType receiverType = receiver.staticType!;
+    DartType receiverType = receiver.typeOrThrow;
 
     if (_typeSystem.isDynamicBounded(receiverType)) {
       _resolveReceiverDynamicBounded(node);
diff --git a/pkg/analyzer/lib/src/dart/resolver/postfix_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/postfix_expression_resolver.dart
index bfac763..39ae692 100644
--- a/pkg/analyzer/lib/src/dart/resolver/postfix_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/postfix_expression_resolver.dart
@@ -8,6 +8,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/error/syntactic_errors.dart';
@@ -206,7 +207,7 @@
     operand.accept(_resolver);
     operand = node.operand;
 
-    var operandType = operand.staticType!;
+    var operandType = operand.typeOrThrow;
 
     var type = _typeSystem.promoteToNonNull(operandType);
     _inferenceHelper.recordStaticType(node, type);
diff --git a/pkg/analyzer/lib/src/dart/resolver/prefix_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/prefix_expression_resolver.dart
index 82f712c..60ee85e 100644
--- a/pkg/analyzer/lib/src/dart/resolver/prefix_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/prefix_expression_resolver.dart
@@ -9,6 +9,7 @@
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/resolver/assignment_expression_resolver.dart';
@@ -154,7 +155,7 @@
         return;
       }
 
-      var readType = node.readType ?? operand.staticType!;
+      var readType = node.readType ?? operand.typeOrThrow;
       if (identical(readType, NeverTypeImpl.instance)) {
         _resolver.errorReporter.reportErrorForNode(
           HintCode.RECEIVER_OF_TYPE_NEVER,
diff --git a/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
index 00317e0..5d0133f 100644
--- a/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -62,7 +63,7 @@
       return _toIndexResult(result);
     }
 
-    var targetType = target.staticType!;
+    var targetType = target.typeOrThrow;
     targetType = _resolveTypeParameter(targetType);
 
     if (targetType.isVoid) {
@@ -343,7 +344,7 @@
       }
     }
 
-    var targetType = target.staticType!;
+    var targetType = target.typeOrThrow;
 
     if (targetType is FunctionType && propertyName.name == 'call') {
       return PropertyElementResolverResult(
diff --git a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
index 6cf4eb2..7dcd3b4 100644
--- a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
@@ -9,6 +9,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_provider.dart';
@@ -155,7 +156,7 @@
 
   DartType _computeElementType(CollectionElement element) {
     if (element is Expression) {
-      return element.staticType!;
+      return element.typeOrThrow;
     } else if (element is ForElement) {
       return _computeElementType(element.body);
     } else if (element is IfElement) {
@@ -173,7 +174,7 @@
       // This error will be reported elsewhere.
       return _typeProvider.dynamicType;
     } else if (element is SpreadElement) {
-      var expressionType = element.expression.staticType!;
+      var expressionType = element.expression.typeOrThrow;
 
       var iterableType = expressionType.asInstanceOf(
         _typeProvider.iterableElement,
@@ -328,7 +329,7 @@
       CollectionElement? element) {
     if (element is Expression) {
       return _InferredCollectionElementTypeInformation(
-          elementType: element.staticType!, keyType: null, valueType: null);
+          elementType: element.typeOrThrow, keyType: null, valueType: null);
     } else if (element is ForElement) {
       return _inferCollectionElementType(element.body);
     } else if (element is IfElement) {
@@ -347,7 +348,7 @@
           keyType: element.key.staticType,
           valueType: element.value.staticType);
     } else if (element is SpreadElement) {
-      var expressionType = element.expression.staticType!;
+      var expressionType = element.expression.typeOrThrow;
 
       var iterableType = expressionType.asInstanceOf(
         _typeProvider.iterableElement,
diff --git a/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
index d0829f0..01fbab4 100644
--- a/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
@@ -6,6 +6,7 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/constant/utilities.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -54,7 +55,7 @@
     initializer = node.initializer;
 
     if (parent.type == null) {
-      _setInferredType(element, initializer!.staticType!);
+      _setInferredType(element, initializer!.typeOrThrow);
     }
 
     if (isTopLevel) {
diff --git a/pkg/analyzer/lib/src/dart/resolver/yield_statement_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/yield_statement_resolver.dart
index 103119a..aa7a684 100644
--- a/pkg/analyzer/lib/src/dart/resolver/yield_statement_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/yield_statement_resolver.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/error/codes.dart';
@@ -72,7 +73,7 @@
     var declaredReturnType = _enclosingFunction.returnType;
 
     var expression = node.expression;
-    var expressionType = expression.staticType!;
+    var expressionType = expression.typeOrThrow;
 
     DartType impliedReturnType;
     if (isYieldEach) {
diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
index 1c32c5c..6b1b894 100644
--- a/pkg/analyzer/lib/src/error/best_practices_verifier.dart
+++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
@@ -39,8 +39,6 @@
 /// Instances of the class `BestPracticesVerifier` traverse an AST structure
 /// looking for violations of Dart best practices.
 class BestPracticesVerifier extends RecursiveAstVisitor<void> {
-  static const String _NULL_TYPE_NAME = "Null";
-
   static const String _TO_INT_METHOD_NAME = "toInt";
 
   /// The class containing the AST nodes being visited, or `null` if we are not
@@ -625,7 +623,7 @@
   void visitPostfixExpression(PostfixExpression node) {
     _deprecatedVerifier.postfixExpression(node);
     if (node.operator.type == TokenType.BANG &&
-        node.operand.staticType!.isDartCoreNull) {
+        node.operand.typeOrThrow.isDartCoreNull) {
       _errorReporter.reportErrorForNode(HintCode.NULL_CHECK_ALWAYS_FAILS, node);
     }
     super.visitPostfixExpression(node);
@@ -717,57 +715,53 @@
       }
       return true;
     }
-    var rhsElement = rhsType.element;
-    var libraryElement = rhsElement?.library;
-    if (libraryElement != null && libraryElement.isDartCore) {
-      // `is Null` or `is! Null`
-      if (rhsNameStr == _NULL_TYPE_NAME) {
-        if (expression is NullLiteral) {
-          if (node.notOperator == null) {
-            _errorReporter.reportErrorForNode(
-              HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
-              node,
-            );
-          } else {
-            _errorReporter.reportErrorForNode(
-              HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
-              node,
-            );
-          }
+    // `is Null` or `is! Null`
+    if (rhsType.isDartCoreNull) {
+      if (expression is NullLiteral) {
+        if (node.notOperator == null) {
+          _errorReporter.reportErrorForNode(
+            HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
+            node,
+          );
         } else {
-          if (node.notOperator == null) {
-            _errorReporter.reportErrorForNode(
-              HintCode.TYPE_CHECK_IS_NULL,
-              node,
-            );
-          } else {
-            _errorReporter.reportErrorForNode(
-              HintCode.TYPE_CHECK_IS_NOT_NULL,
-              node,
-            );
-          }
+          _errorReporter.reportErrorForNode(
+            HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
+            node,
+          );
+        }
+      } else {
+        if (node.notOperator == null) {
+          _errorReporter.reportErrorForNode(
+            HintCode.TYPE_CHECK_IS_NULL,
+            node,
+          );
+        } else {
+          _errorReporter.reportErrorForNode(
+            HintCode.TYPE_CHECK_IS_NOT_NULL,
+            node,
+          );
+        }
+      }
+      return true;
+    }
+    // `is Object` or `is! Object`
+    if (rhsType.isDartCoreObject) {
+      var nullability = rhsType.nullabilitySuffix;
+      if (nullability == NullabilitySuffix.star ||
+          nullability == NullabilitySuffix.question) {
+        if (node.notOperator == null) {
+          _errorReporter.reportErrorForNode(
+            HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
+            node,
+          );
+        } else {
+          _errorReporter.reportErrorForNode(
+            HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
+            node,
+          );
         }
         return true;
       }
-      // `is Object` or `is! Object`
-      if (rhsType.isDartCoreObject) {
-        var nullability = rhsType.nullabilitySuffix;
-        if (nullability == NullabilitySuffix.star ||
-            nullability == NullabilitySuffix.question) {
-          if (node.notOperator == null) {
-            _errorReporter.reportErrorForNode(
-              HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
-              node,
-            );
-          } else {
-            _errorReporter.reportErrorForNode(
-              HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
-              node,
-            );
-          }
-          return true;
-        }
-      }
     }
     return false;
   }
@@ -1079,14 +1073,14 @@
 
     void checkLeftRight(HintCode errorCode) {
       if (node.leftOperand is NullLiteral) {
-        var rightType = node.rightOperand.staticType!;
+        var rightType = node.rightOperand.typeOrThrow;
         if (_typeSystem.isStrictlyNonNullable(rightType)) {
           reportStartEnd(errorCode, node.leftOperand, node.operator);
         }
       }
 
       if (node.rightOperand is NullLiteral) {
-        var leftType = node.leftOperand.staticType!;
+        var leftType = node.leftOperand.typeOrThrow;
         if (_typeSystem.isStrictlyNonNullable(leftType)) {
           reportStartEnd(errorCode, node.operator, node.rightOperand);
         }
@@ -1597,7 +1591,7 @@
   /// Returns `true` if and only if an unnecessary cast hint should be generated
   /// on [node].  See [HintCode.UNNECESSARY_CAST].
   static bool isUnnecessaryCast(AsExpression node, TypeSystemImpl typeSystem) {
-    var leftType = node.expression.staticType!;
+    var leftType = node.expression.typeOrThrow;
     var rightType = node.type.type!;
 
     // `dynamicValue as SomeType` is a valid use case.
@@ -1630,13 +1624,13 @@
           : parent.thenExpression;
 
       var currentType = typeSystem.leastUpperBound(
-        node.staticType!,
-        other.staticType!,
+        node.typeOrThrow,
+        other.typeOrThrow,
       );
 
       var typeWithoutCast = typeSystem.leastUpperBound(
-        node.expression.staticType!,
-        other.staticType!,
+        node.expression.typeOrThrow,
+        other.typeOrThrow,
       );
 
       if (typeWithoutCast != currentType) {
diff --git a/pkg/analyzer/lib/src/error/bool_expression_verifier.dart b/pkg/analyzer/lib/src/error/bool_expression_verifier.dart
index 3324386..79d5369 100644
--- a/pkg/analyzer/lib/src/error/bool_expression_verifier.dart
+++ b/pkg/analyzer/lib/src/error/bool_expression_verifier.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/error/codes.dart';
@@ -18,7 +18,6 @@
   final ErrorReporter _errorReporter;
   final NullableDereferenceVerifier _nullableDereferenceVerifier;
 
-  final ClassElement _boolElement;
   final InterfaceType _boolType;
 
   BoolExpressionVerifier({
@@ -28,7 +27,6 @@
   })   : _typeSystem = typeSystem,
         _errorReporter = errorReporter,
         _nullableDereferenceVerifier = nullableDereferenceVerifier,
-        _boolElement = typeSystem.typeProvider.boolElement,
         _boolType = typeSystem.typeProvider.boolType;
 
   /// Check to ensure that the [condition] is of type bool, are. Otherwise an
@@ -46,10 +44,10 @@
   /// [errorCode] if not, or a nullability error if its improperly nullable.
   void checkForNonBoolExpression(Expression expression,
       {required ErrorCode errorCode, List<Object>? arguments}) {
-    var type = expression.staticType!;
+    var type = expression.typeOrThrow;
     if (!_checkForUseOfVoidResult(expression) &&
         !_typeSystem.isAssignableTo(type, _boolType)) {
-      if (type.element == _boolElement) {
+      if (type.isDartCoreBool) {
         _nullableDereferenceVerifier.report(expression, type,
             errorCode: CompileTimeErrorCode
                 .UNCHECKED_USE_OF_NULLABLE_VALUE_AS_CONDITION);
diff --git a/pkg/analyzer/lib/src/error/catch_error_verifier.dart b/pkg/analyzer/lib/src/error/catch_error_verifier.dart
index da72645..08a8a52 100644
--- a/pkg/analyzer/lib/src/error/catch_error_verifier.dart
+++ b/pkg/analyzer/lib/src/error/catch_error_verifier.dart
@@ -6,6 +6,7 @@
 import 'package:analyzer/dart/ast/visitor.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type_provider.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/error/codes.dart';
@@ -36,7 +37,7 @@
     }
     var methodName = node.methodName;
     if (!(methodName.name == 'catchError' &&
-        target.staticType!.isDartAsyncFuture)) {
+        target.typeOrThrow.isDartAsyncFuture)) {
       return;
     }
     if (node.argumentList.arguments.isEmpty) {
diff --git a/pkg/analyzer/lib/src/error/literal_element_verifier.dart b/pkg/analyzer/lib/src/error/literal_element_verifier.dart
index d62271b..b6c3c4e 100644
--- a/pkg/analyzer/lib/src/error/literal_element_verifier.dart
+++ b/pkg/analyzer/lib/src/error/literal_element_verifier.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/error/codes.dart';
@@ -68,7 +69,7 @@
         if (!elementType!.isVoid && checkForUseOfVoidResult(element)) {
           return;
         }
-        _checkAssignableToElementType(element.staticType!, element);
+        _checkAssignableToElementType(element.typeOrThrow, element);
       } else {
         errorReporter.reportErrorForNode(
             CompileTimeErrorCode.EXPRESSION_IN_MAP, element);
@@ -107,7 +108,7 @@
       return;
     }
 
-    var keyType = entry.key.staticType!;
+    var keyType = entry.key.typeOrThrow;
     if (!typeSystem.isAssignableTo(keyType, mapKeyType!)) {
       errorReporter.reportErrorForNode(
         CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
@@ -116,7 +117,7 @@
       );
     }
 
-    var valueType = entry.value.staticType!;
+    var valueType = entry.value.typeOrThrow;
     if (!typeSystem.isAssignableTo(valueType, mapValueType!)) {
       errorReporter.reportErrorForNode(
         CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
@@ -129,7 +130,7 @@
   /// Verify that the type of the elements of the given [expression] can be
   /// assigned to the [elementType] of the enclosing collection.
   void _verifySpreadForListOrSet(bool isNullAware, Expression expression) {
-    var expressionType = expression.staticType!;
+    var expressionType = expression.typeOrThrow;
     if (expressionType.isDynamic) return;
 
     if (typeSystem.isNonNullableByDefault) {
@@ -186,7 +187,7 @@
   /// Verify that the [expression] is a subtype of `Map<Object, Object>`, and
   /// its key and values are assignable to [mapKeyType] and [mapValueType].
   void _verifySpreadForMap(bool isNullAware, Expression expression) {
-    var expressionType = expression.staticType!;
+    var expressionType = expression.typeOrThrow;
     if (expressionType.isDynamic) return;
 
     if (typeSystem.isNonNullableByDefault) {
diff --git a/pkg/analyzer/lib/src/error/nullable_dereference_verifier.dart b/pkg/analyzer/lib/src/error/nullable_dereference_verifier.dart
index 1b5f219..48816ec 100644
--- a/pkg/analyzer/lib/src/error/nullable_dereference_verifier.dart
+++ b/pkg/analyzer/lib/src/error/nullable_dereference_verifier.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/diagnostic/diagnostic.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/error/codes.dart';
@@ -28,7 +29,7 @@
       return false;
     }
 
-    type ??= expression.staticType!;
+    type ??= expression.typeOrThrow;
     return _check(expression, type, errorCode: errorCode);
   }
 
diff --git a/pkg/analyzer/lib/src/error/return_type_verifier.dart b/pkg/analyzer/lib/src/error/return_type_verifier.dart
index 38aad2a..fcb2f6f 100644
--- a/pkg/analyzer/lib/src/error/return_type_verifier.dart
+++ b/pkg/analyzer/lib/src/error/return_type_verifier.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/nullability_suffix.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_provider.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -151,7 +152,7 @@
     // `T` is the declared return type.
     // `S` is the static type of the expression.
     var T = enclosingExecutable.returnType;
-    var S = expression.staticType!;
+    var S = expression.typeOrThrow;
 
     void reportTypeError() {
       if (enclosingExecutable.catchErrorOnErrorReturnType != null) {
@@ -258,7 +259,7 @@
     // `T` is the declared return type.
     // `S` is the static type of the expression.
     var T = enclosingExecutable.returnType;
-    var S = expression.staticType!;
+    var S = expression.typeOrThrow;
 
     void reportTypeError() {
       if (enclosingExecutable.catchErrorOnErrorReturnType != null) {
diff --git a/pkg/analyzer/lib/src/error/type_arguments_verifier.dart b/pkg/analyzer/lib/src/error/type_arguments_verifier.dart
index 642a37f..568f81a 100644
--- a/pkg/analyzer/lib/src/error/type_arguments_verifier.dart
+++ b/pkg/analyzer/lib/src/error/type_arguments_verifier.dart
@@ -9,6 +9,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type_algebra.dart';
 import 'package:analyzer/src/dart/element/type_schema.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -138,7 +139,7 @@
     if (_options.implicitDynamic || node.typeArguments != null) {
       return;
     }
-    DartType type = node.staticType!;
+    DartType type = node.typeOrThrow;
     // It's an error if either the key or value was inferred as dynamic.
     if (type is InterfaceType && type.typeArguments.any((t) => t.isDynamic)) {
       // TODO(brianwilkerson) Add StrongModeCode.IMPLICIT_DYNAMIC_SET_LITERAL
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index 3974134..f82bc93 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -92,12 +92,6 @@
   /// The suffix used for Dart source files.
   static const String SUFFIX_DART = "dart";
 
-  /// The short suffix used for HTML files.
-  static const String SUFFIX_HTM = "htm";
-
-  /// The long suffix used for HTML files.
-  static const String SUFFIX_HTML = "html";
-
   /// The file name used for analysis options files.
   static const String ANALYSIS_OPTIONS_YAML_FILE = 'analysis_options.yaml';
 
@@ -167,7 +161,7 @@
     return extension == SUFFIX_DART;
   }
 
-  /// Return `true` if the given [fileName] is AndroidManifest.xml
+  /// Return `true` if the given [fileName] is AndroidManifest.xml.
   static bool isManifestFileName(String? fileName) {
     if (fileName == null) {
       return false;
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 215b4da..f0cf878 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -764,7 +764,7 @@
       return super.visitFunctionExpressionInvocation(node);
     }
 
-    DartType expressionType = functionExpression.staticType!;
+    DartType expressionType = functionExpression.typeOrThrow;
     if (!_checkForUseOfVoidResult(functionExpression) &&
         !_checkForUseOfNever(functionExpression) &&
         node.staticElement == null &&
@@ -1594,7 +1594,7 @@
       DartType? expectedStaticType,
       ErrorCode errorCode) {
     _checkForArgumentTypeNotAssignable(
-        expression, expectedStaticType, expression.staticType!, errorCode);
+        expression, expectedStaticType, expression.typeOrThrow, errorCode);
   }
 
   /// Verify that the arguments in the given [argumentList] can be assigned to
@@ -1612,7 +1612,7 @@
 
   bool _checkForAssignableExpression(
       Expression expression, DartType expectedStaticType, ErrorCode errorCode) {
-    DartType actualStaticType = expression.staticType!;
+    DartType actualStaticType = expression.typeOrThrow;
     return _checkForAssignableExpressionAtType(
         expression, actualStaticType, expectedStaticType, errorCode);
   }
@@ -2284,7 +2284,7 @@
       return false;
     }
 
-    DartType iterableType = node.iterable.staticType!;
+    DartType iterableType = node.iterable.typeOrThrow;
 
     // TODO(scheglov) use NullableDereferenceVerifier
     if (_isNonNullableByDefault) {
@@ -2519,7 +2519,7 @@
     // prepare expression type
     Expression expression = initializer.expression;
     // test the static type of the expression
-    DartType staticType = expression.staticType!;
+    DartType staticType = expression.typeOrThrow;
     if (_typeSystem.isAssignableTo(staticType, fieldType)) {
       if (!fieldType.isVoid) {
         _checkForUseOfVoidResult(expression);
@@ -2885,7 +2885,7 @@
     } else {
       var leftVariableElement = getVariableElement(lhs);
       leftType = (leftVariableElement == null)
-          ? lhs.staticType!
+          ? lhs.typeOrThrow
           : leftVariableElement.type;
     }
 
@@ -3051,7 +3051,7 @@
     // Determine the list's element type. We base this on the static type and
     // not the literal's type arguments because in strong mode, the type
     // arguments may be inferred.
-    DartType listType = literal.staticType!;
+    DartType listType = literal.typeOrThrow;
     assert(listType is InterfaceTypeImpl);
 
     List<DartType> typeArguments =
@@ -3137,7 +3137,7 @@
     // Determine the map's key and value types. We base this on the static type
     // and not the literal's type arguments because in strong mode, the type
     // arguments may be inferred.
-    DartType mapType = literal.staticType!;
+    DartType mapType = literal.typeOrThrow;
     assert(mapType is InterfaceTypeImpl);
 
     List<DartType> typeArguments = (mapType as InterfaceTypeImpl).typeArguments;
@@ -4095,7 +4095,7 @@
     // Determine the set's element type. We base this on the static type and
     // not the literal's type arguments because in strong mode, the type
     // arguments may be inferred.
-    DartType setType = literal.staticType!;
+    DartType setType = literal.typeOrThrow;
     assert(setType is InterfaceTypeImpl);
 
     List<DartType> typeArguments = (setType as InterfaceTypeImpl).typeArguments;
@@ -4166,7 +4166,7 @@
     }
 
     // prepare 'switch' expression type
-    DartType expressionType = expression.staticType!;
+    DartType expressionType = expression.typeOrThrow;
 
     // compare with type of the first non-default 'case'
     var switchCase = statement.members.whereType<SwitchCase>().firstOrNull;
@@ -4175,7 +4175,7 @@
     }
 
     Expression caseExpression = switchCase.expression;
-    DartType caseType = caseExpression.staticType!;
+    DartType caseType = caseExpression.typeOrThrow;
 
     // check types
     if (!_typeSystem.isAssignableTo(expressionType, caseType)) {
@@ -4190,7 +4190,7 @@
     if (!_isNonNullableByDefault) return;
 
     var expression = node.expression;
-    var type = node.expression.staticType!;
+    var type = node.expression.typeOrThrow;
 
     if (!_typeSystem.isAssignableTo(type, _typeSystem.objectNone)) {
       _errorReporter.reportErrorForNode(
@@ -4416,7 +4416,7 @@
     if (target is ExtensionOverride) {
       var arguments = target.argumentList.arguments;
       if (arguments.length == 1) {
-        targetType = arguments[0].staticType!;
+        targetType = arguments[0].typeOrThrow;
       } else {
         return;
       }
@@ -4836,7 +4836,8 @@
     }
 
     for (var interfaceNode in implementsClause.interfaces) {
-      if (interfaceNode.type!.element == superElement) {
+      var type = interfaceNode.type;
+      if (type is InterfaceType && type.element == superElement) {
         _errorReporter.reportErrorForNode(
           CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS,
           interfaceNode,
@@ -4958,7 +4959,8 @@
     }
 
     for (var mixinNode in withClause.mixinTypes) {
-      if (mixinNode.type!.element == superElement) {
+      var type = mixinNode.type;
+      if (type is InterfaceType && type.element == superElement) {
         _errorReporter.reportErrorForNode(
           CompileTimeErrorCode.MIXINS_SUPER_CLASS,
           mixinNode,
diff --git a/pkg/analyzer/lib/src/generated/ffi_verifier.dart b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
index 8d0ed8b..16e000f 100644
--- a/pkg/analyzer/lib/src/generated/ffi_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/error/ffi_code.dart';
 
@@ -766,7 +767,7 @@
     }
 
     Expression f = node.argumentList.arguments[0];
-    DartType FT = f.staticType!;
+    DartType FT = f.typeOrThrow;
     if (!_validateCompatibleFunctionTypes(FT, T)) {
       _errorReporter.reportErrorForNode(
           FfiCode.MUST_BE_A_SUBTYPE, f, [f.staticType, T, 'fromFunction']);
@@ -789,7 +790,7 @@
     } else {
       Expression e = node.argumentList.arguments[1];
       // TODO(brianwilkerson) Validate that `e` is a constant expression.
-      if (!_validateCompatibleNativeType(e.staticType!, R, true)) {
+      if (!_validateCompatibleNativeType(e.typeOrThrow, R, true)) {
         _errorReporter.reportErrorForNode(
             FfiCode.MUST_BE_A_SUBTYPE, e, [e.staticType, R, 'fromFunction']);
       }
@@ -845,7 +846,7 @@
   /// Validate the invocation of the extension method
   /// `Pointer<T extends Struct>.ref`.
   void _validateRefPrefixedIdentifier(PrefixedIdentifier node) {
-    var targetType = node.prefix.staticType!;
+    var targetType = node.prefix.typeOrThrow;
     if (!_isValidFfiNativeType(targetType,
         allowVoid: false, allowEmptyStruct: true)) {
       final AstNode errorNode = node;
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index e2c8920..9e441f9 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -15,6 +15,7 @@
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
 import 'package:analyzer/src/dart/element/member.dart'
@@ -886,14 +887,14 @@
       if (isIdentical && length > 1 && i == 1) {
         var firstArg = arguments[0];
         flowAnalysis?.flow
-            ?.equalityOp_rightBegin(firstArg, firstArg.staticType!);
+            ?.equalityOp_rightBegin(firstArg, firstArg.typeOrThrow);
       }
       arguments[i].accept(this);
     }
     if (isIdentical && length > 1) {
       var secondArg = arguments[1];
       flowAnalysis?.flow?.equalityOp_end(
-          node.parent as Expression, secondArg, secondArg.staticType!);
+          node.parent as Expression, secondArg, secondArg.typeOrThrow);
     }
     node.accept(elementResolver);
     node.accept(typeAnalyzer);
@@ -1925,7 +1926,7 @@
       expression.accept(this);
       expression = node.expression;
 
-      _enclosingSwitchStatementExpressionType = expression.staticType!;
+      _enclosingSwitchStatementExpressionType = expression.typeOrThrow;
 
       if (flowAnalysis != null) {
         var flow = flowAnalysis!.flow!;
@@ -2026,7 +2027,7 @@
     var parent = node.parent as VariableDeclarationList;
     var declaredType = parent.type;
     if (initializer != null) {
-      var initializerStaticType = initializer.staticType!;
+      var initializerStaticType = initializer.typeOrThrow;
       if (declaredType == null) {
         if (initializerStaticType is TypeParameterType) {
           flowAnalysis?.flow?.promote(
@@ -2357,7 +2358,7 @@
       var subexpressionToKeep =
           conditionalKnownValue ? node.thenExpression : node.elseExpression;
       subexpressionToKeep.accept(this);
-      typeAnalyzer.recordStaticType(node, subexpressionToKeep.staticType!);
+      typeAnalyzer.recordStaticType(node, subexpressionToKeep.typeOrThrow);
     }
   }
 
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index ab454da..96b116d 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -8,6 +8,7 @@
 import 'package:analyzer/dart/element/nullability_suffix.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/member.dart' show ConstructorMember;
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_provider.dart';
@@ -111,7 +112,7 @@
   ///   the static type of e.
   @override
   void visitAwaitExpression(AwaitExpression node) {
-    var resultType = node.expression.staticType!;
+    var resultType = node.expression.typeOrThrow;
     resultType = _typeSystem.flatten(resultType);
     recordStaticType(node, resultType);
   }
@@ -128,7 +129,7 @@
   /// t;}(e)</i>.</blockquote>
   @override
   void visitCascadeExpression(CascadeExpression node) {
-    recordStaticType(node, node.target.staticType!);
+    recordStaticType(node, node.target.typeOrThrow);
   }
 
   /// The Dart Language Specification, 12.19: <blockquote> ... a conditional expression <i>c</i> of
@@ -245,7 +246,7 @@
   @override
   void visitNamedExpression(NamedExpression node) {
     Expression expression = node.expression;
-    recordStaticType(node, expression.staticType!);
+    recordStaticType(node, expression.typeOrThrow);
   }
 
   /// The Dart Language Specification, 12.2: <blockquote>The static type of `null` is bottom.
@@ -258,7 +259,7 @@
   @override
   void visitParenthesizedExpression(ParenthesizedExpression node) {
     Expression expression = node.expression;
-    recordStaticType(node, expression.staticType!);
+    recordStaticType(node, expression.typeOrThrow);
   }
 
   /// The Dart Language Specification, 12.9: <blockquote>The static type of a rethrow expression is
@@ -327,8 +328,8 @@
   /// types of subexpressions [expr1] and [expr2].
   void _analyzeLeastUpperBound(
       Expression node, Expression expr1, Expression expr2) {
-    var staticType1 = expr1.staticType!;
-    var staticType2 = expr2.staticType!;
+    var staticType1 = expr1.typeOrThrow;
+    var staticType2 = expr2.typeOrThrow;
 
     _analyzeLeastUpperBoundTypes(node, staticType1, staticType2);
   }
diff --git a/pkg/analyzer/lib/src/generated/type_promotion_manager.dart b/pkg/analyzer/lib/src/generated/type_promotion_manager.dart
index bf956ef..de3e0a0 100644
--- a/pkg/analyzer/lib/src/generated/type_promotion_manager.dart
+++ b/pkg/analyzer/lib/src/generated/type_promotion_manager.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/ast/visitor.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/generated/variable_type_provider.dart';
 
@@ -235,7 +236,7 @@
         return;
       }
       // prepare current variable type
-      DartType type = _getPromotedType(element) ?? expression.staticType!;
+      DartType type = _getPromotedType(element) ?? expression.typeOrThrow;
 
       // Check if we can promote to potentialType from type.
       var promoteType = _typeSystem.tryPromoteToType(potentialType, type);
diff --git a/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart b/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
index b69c770..336b180 100644
--- a/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
+++ b/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
@@ -10,6 +10,7 @@
 import 'package:analyzer/dart/element/type_provider.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:pub_semver/pub_semver.dart';
 
@@ -131,7 +132,7 @@
               operatorType == TokenType.BAR ||
               operatorType == TokenType.CARET) &&
           (node as BinaryExpressionImpl).inConstantContext) {
-        if (node.leftOperand.staticType!.isDartCoreBool) {
+        if (node.leftOperand.typeOrThrow.isDartCoreBool) {
           _errorReporter.reportErrorForToken(
               HintCode.SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT,
               node.operator,
@@ -140,7 +141,7 @@
       } else if (operatorType == TokenType.EQ_EQ &&
           (node as BinaryExpressionImpl).inConstantContext) {
         bool primitive(Expression node) {
-          DartType type = node.staticType!;
+          DartType type = node.typeOrThrow;
           return type.isDartCoreBool ||
               type.isDartCoreDouble ||
               type.isDartCoreInt ||
diff --git a/pkg/analyzer/lib/src/summary2/apply_resolution.dart b/pkg/analyzer/lib/src/summary2/apply_resolution.dart
index abe0727..92522a1 100644
--- a/pkg/analyzer/lib/src/summary2/apply_resolution.dart
+++ b/pkg/analyzer/lib/src/summary2/apply_resolution.dart
@@ -349,8 +349,9 @@
 
     var enclosing = _enclosingElements.last;
     var name = node.identifier?.name ?? '';
-    var reference = node.isNamed && enclosing.reference != null
-        ? enclosing.reference!.getChild('@parameter').getChild(name)
+    var enclosingReference = enclosing.reference;
+    var reference = node.isNamed && enclosingReference != null
+        ? enclosingReference.getChild('@parameter').getChild(name)
         : null;
     ParameterElementImpl element;
     if (node.parameter is FieldFormalParameter) {
@@ -475,11 +476,12 @@
 
   @override
   void visitFieldFormalParameter(FieldFormalParameter node) {
-    ParameterElementImpl? element;
-    if (node.parent is! DefaultFormalParameter) {
+    if (node.declaredElement == null) {
+      assert(node.parent is! DefaultFormalParameter);
       var enclosing = _enclosingElements.last;
-      element =
+      var element =
           FieldFormalParameterElementImpl.forLinkedNode(enclosing, null, node);
+      _normalFormalParameterNotDefault(node, element);
     }
 
     var localElementsLength = _localElements.length;
@@ -491,7 +493,7 @@
     _expectMarker(MarkerTag.FieldFormalParameter_parameters);
     node.parameters?.accept(this);
     _expectMarker(MarkerTag.FieldFormalParameter_normalFormalParameter);
-    _normalFormalParameter(node, element);
+    _normalFormalParameter(node);
     _expectMarker(MarkerTag.FieldFormalParameter_end);
 
     _localElements.length = localElementsLength;
@@ -625,11 +627,12 @@
 
   @override
   void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
-    var element = node.declaredElement as ParameterElementImpl?;
-    if (node.parent is! DefaultFormalParameter) {
+    if (node.declaredElement == null) {
+      assert(node.parent is! DefaultFormalParameter);
       var enclosing = _enclosingElements.last;
-      element =
+      var element =
           ParameterElementImpl.forLinkedNodeFactory(enclosing, null, node);
+      _normalFormalParameterNotDefault(node, element);
     }
 
     var localElementsLength = _localElements.length;
@@ -641,7 +644,7 @@
     _expectMarker(MarkerTag.FunctionTypedFormalParameter_parameters);
     node.parameters.accept(this);
     _expectMarker(MarkerTag.FunctionTypedFormalParameter_normalFormalParameter);
-    _normalFormalParameter(node, element);
+    _normalFormalParameter(node);
     _expectMarker(MarkerTag.FunctionTypedFormalParameter_end);
 
     _localElements.length = localElementsLength;
@@ -1139,15 +1142,17 @@
   visitSimpleFormalParameter(SimpleFormalParameter node) {
     var element = node.declaredElement as ParameterElementImpl?;
     if (element == null) {
+      assert(node.parent is! DefaultFormalParameter);
       var enclosing = _enclosingElements.last;
       element =
           ParameterElementImpl.forLinkedNodeFactory(enclosing, null, node);
+      _normalFormalParameterNotDefault(node, element);
     }
 
     _expectMarker(MarkerTag.SimpleFormalParameter_type);
     node.type?.accept(this);
     _expectMarker(MarkerTag.SimpleFormalParameter_normalFormalParameter);
-    _normalFormalParameter(node, element);
+    _normalFormalParameter(node);
 
     _expectMarker(MarkerTag.SimpleFormalParameter_flags);
     element.inheritsCovariant = _resolution.readByte() != 0;
@@ -1477,16 +1482,7 @@
     return _resolution.nextType();
   }
 
-  void _normalFormalParameter(
-    NormalFormalParameter node,
-    ParameterElementImpl? element,
-  ) {
-    if (node.parent is! DefaultFormalParameter) {
-      var nodeImpl = node as NormalFormalParameterImpl;
-      var summaryData = nodeImpl.summaryData as SummaryDataForFormalParameter;
-      element!.setCodeRange(summaryData.codeOffset, summaryData.codeLength);
-    }
-
+  void _normalFormalParameter(NormalFormalParameter node) {
     _expectMarker(MarkerTag.NormalFormalParameter_metadata);
     node.metadata.accept(this);
     _expectMarker(MarkerTag.NormalFormalParameter_formalParameter);
@@ -1494,6 +1490,13 @@
     _expectMarker(MarkerTag.NormalFormalParameter_end);
   }
 
+  void _normalFormalParameterNotDefault(
+      NormalFormalParameter node, ParameterElementImpl element) {
+    var nodeImpl = node as NormalFormalParameterImpl;
+    var summaryData = nodeImpl.summaryData as SummaryDataForFormalParameter;
+    element.setCodeRange(summaryData.codeOffset, summaryData.codeLength);
+  }
+
   /// TODO(scheglov) also enclosing elements
   void _pushEnclosingClassTypeParameters(ClassMember node) {
     var parent = node.parent;
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
index d2cc77b..6e7a6d3 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
@@ -27,7 +27,6 @@
   final StringIndexer _stringIndexer;
   final int Function() _getNextResolutionIndex;
   final ResolutionSink? _resolutionSink;
-  final bool _shouldWriteResolution;
 
   /// TODO(scheglov) Keep it private, and write here, similarly as we do
   /// for [_classMemberIndexItems]?
@@ -47,8 +46,7 @@
         _sink = sink,
         _stringIndexer = stringIndexer,
         _getNextResolutionIndex = getNextResolutionIndex,
-        _resolutionSink = resolutionSink,
-        _shouldWriteResolution = resolutionSink != null;
+        _resolutionSink = resolutionSink;
 
   @override
   void visitAdjacentStrings(AdjacentStrings node) {
@@ -74,9 +72,10 @@
     }
     _writeOptionalNode(arguments);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.Annotation_element);
-      _resolutionSink!.writeElement(node.element);
+      resolutionSink.writeElement(node.element);
     }
   }
 
@@ -127,17 +126,18 @@
     var binaryToken = TokensWriter.astToBinaryTokenType(operatorToken);
     _writeByte(binaryToken.index);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.AssignmentExpression_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
       _writeMarker(MarkerTag.AssignmentExpression_readElement);
-      _resolutionSink!.writeElement(node.readElement);
+      resolutionSink.writeElement(node.readElement);
       _writeMarker(MarkerTag.AssignmentExpression_readType);
-      _resolutionSink!.writeType(node.readType);
+      resolutionSink.writeType(node.readType);
       _writeMarker(MarkerTag.AssignmentExpression_writeElement);
-      _resolutionSink!.writeElement(node.writeElement);
+      resolutionSink.writeElement(node.writeElement);
       _writeMarker(MarkerTag.AssignmentExpression_writeType);
-      _resolutionSink!.writeType(node.writeType);
+      resolutionSink.writeType(node.writeType);
     }
     _writeMarker(MarkerTag.AssignmentExpression_expression);
     _storeExpression(node);
@@ -170,9 +170,10 @@
     var binaryToken = TokensWriter.astToBinaryTokenType(operatorToken);
     _writeByte(binaryToken.index);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.BinaryExpression_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
     }
     _writeMarker(MarkerTag.BinaryExpression_expression);
     _storeExpression(node);
@@ -183,9 +184,7 @@
   void visitBooleanLiteral(BooleanLiteral node) {
     _writeByte(Tag.BooleanLiteral);
     _writeByte(node.value ? 1 : 0);
-    if (_shouldWriteResolution) {
-      _storeExpression(node);
-    }
+    _storeExpression(node);
   }
 
   @override
@@ -218,8 +217,11 @@
         isAbstract: node.abstractKeyword != null,
       ),
     );
-    if (_shouldWriteResolution) {
-      _resolutionSink!.writeByte(node.declaredElement!.isSimplyBounded ? 1 : 0);
+
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      var element = node.declaredElement as ClassElementImpl;
+      resolutionSink.writeByte(element.isSimplyBounded ? 1 : 0);
     }
 
     _writeInformativeUint30(node.offset);
@@ -247,8 +249,8 @@
     _writeNodeList(node.members);
     _hasConstConstructor = false;
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
 
     // TODO(scheglov) write member index
@@ -283,9 +285,13 @@
         isAbstract: node.abstractKeyword != null,
       ),
     );
-    if (_shouldWriteResolution) {
-      _resolutionSink!.writeByte(node.declaredElement!.isSimplyBounded ? 1 : 0);
+
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      var element = node.declaredElement as ClassElementImpl;
+      resolutionSink.writeByte(element.isSimplyBounded ? 1 : 0);
     }
+
     _writeInformativeUint30(node.offset);
     _writeInformativeUint30(node.length);
     _pushScopeTypeParameters(node.typeParameters);
@@ -302,8 +308,9 @@
     _writeMarker(MarkerTag.ClassTypeAlias_end);
     _writeDocumentationCommentString(node.documentationComment);
     _writeUInt30(resolutionIndex);
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
   }
 
@@ -382,17 +389,21 @@
     var resolutionIndex = _getNextResolutionIndex();
     _writeMarker(MarkerTag.ConstructorDeclaration_returnType);
     _writeNode(node.returnType);
-    if (node.period != null) {
-      _writeInformativeUint30(node.period!.offset);
+
+    var period = node.period;
+    if (period != null) {
+      _writeInformativeUint30(period.offset);
       _writeDeclarationName(node.name!);
     }
+
     _writeMarker(MarkerTag.ConstructorDeclaration_parameters);
     _writeNode(node.parameters);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.pushScope();
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.localElements.pushScope();
       for (var parameter in node.parameters.parameters) {
-        _resolutionSink!.localElements.declare(parameter.declaredElement!);
+        resolutionSink.localElements.declare(parameter.declaredElement!);
       }
     }
 
@@ -405,8 +416,8 @@
       _writeNodeList(const <ConstructorInitializer>[]);
     }
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
 
     _writeMarker(MarkerTag.ConstructorDeclaration_redirectedConstructor);
@@ -438,12 +449,13 @@
   void visitConstructorName(ConstructorName node) {
     _writeByte(Tag.ConstructorName);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       // When we parse `C() = A.named` we don't know that `A` is a class name.
       // We parse it as a `TypeName(PrefixedIdentifier)`.
       // But when we resolve, we rewrite it.
       // We need to inform the applier about the right shape of the AST.
-      _resolutionSink!.writeByte(node.name != null ? 1 : 0);
+      resolutionSink.writeByte(node.name != null ? 1 : 0);
     }
 
     _writeMarker(MarkerTag.ConstructorName_type);
@@ -451,9 +463,9 @@
     _writeMarker(MarkerTag.ConstructorName_name);
     _writeOptionalNode(node.name);
 
-    if (_shouldWriteResolution) {
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.ConstructorName_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
     }
 
     _writeMarker(MarkerTag.ConstructorName_end);
@@ -566,9 +578,10 @@
     _storeNamespaceDirective(node);
     _writeUInt30(resolutionIndex);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.ExportDirective_exportedLibrary);
-      _resolutionSink!.writeElement(
+      resolutionSink.writeElement(
         (node.element as ExportElementImpl).exportedLibrary,
       );
     }
@@ -609,8 +622,9 @@
     _classMemberIndexItems.clear();
     _writeNodeList(node.members);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
 
     // TODO(scheglov) write member index
@@ -635,8 +649,9 @@
   void visitExtensionOverride(ExtensionOverride node) {
     _writeByte(Tag.ExtensionOverride);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.writeByte(MethodInvocationRewriteTag.extensionOverride);
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.writeByte(MethodInvocationRewriteTag.extensionOverride);
     }
 
     _writeMarker(MarkerTag.ExtensionOverride_extensionName);
@@ -646,7 +661,11 @@
     _writeMarker(MarkerTag.ExtensionOverride_argumentList);
     _writeNode(node.argumentList);
     _writeMarker(MarkerTag.ExtensionOverride_extendedType);
-    _resolutionSink!.writeType(node.extendedType);
+
+    if (resolutionSink != null) {
+      resolutionSink.writeType(node.extendedType);
+    }
+
     _writeMarker(MarkerTag.ExtensionOverride_end);
     // TODO(scheglov) typeArgumentTypes?
   }
@@ -711,8 +730,9 @@
     );
     _writeMarker(MarkerTag.FieldFormalParameter_end);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
   }
 
@@ -820,10 +840,12 @@
     _writeMarker(MarkerTag.FunctionDeclaration_namedCompilationUnitMember);
     _storeNamedCompilationUnitMember(node);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      var element = node.declaredElement as ExecutableElementImpl;
       _writeMarker(MarkerTag.FunctionDeclaration_returnTypeType);
-      _writeActualReturnType(node.declaredElement!.returnType);
-      _resolutionSink!.localElements.popScope();
+      _writeActualReturnType(resolutionSink, element.returnType);
+      resolutionSink.localElements.popScope();
     }
 
     _writeMarker(MarkerTag.FunctionDeclaration_end);
@@ -854,9 +876,11 @@
   void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
     _writeByte(Tag.FunctionExpressionInvocation);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!
-          .writeByte(MethodInvocationRewriteTag.functionExpressionInvocation);
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.writeByte(
+        MethodInvocationRewriteTag.functionExpressionInvocation,
+      );
     }
 
     _writeMarker(MarkerTag.FunctionExpressionInvocation_function);
@@ -897,16 +921,17 @@
     _writeMarker(MarkerTag.FunctionTypeAlias_typeAlias);
     _storeTypeAlias(node);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.declaredElement as FunctionTypeAliasElementImpl;
       _writeMarker(MarkerTag.FunctionTypeAlias_returnTypeType);
-      _writeActualReturnType(element.function.returnType);
+      _writeActualReturnType(resolutionSink, element.function.returnType);
       // TODO(scheglov) pack into one byte
       _writeMarker(MarkerTag.FunctionTypeAlias_flags);
-      _resolutionSink!.writeByte(element.isSimplyBounded ? 1 : 0);
-      _resolutionSink!.writeByte(element.hasSelfReference ? 1 : 0);
+      resolutionSink.writeByte(element.isSimplyBounded ? 1 : 0);
+      resolutionSink.writeByte(element.hasSelfReference ? 1 : 0);
 
-      _resolutionSink!.localElements.popScope();
+      resolutionSink.localElements.popScope();
     }
 
     _writeMarker(MarkerTag.FunctionTypeAlias_end);
@@ -929,8 +954,9 @@
     _storeNormalFormalParameter(node, null);
     _writeMarker(MarkerTag.FunctionTypedFormalParameter_end);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
   }
 
@@ -953,10 +979,11 @@
     _writeMarker(MarkerTag.GenericFunctionType_parameters);
     _writeNode(node.parameters);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.GenericFunctionType_type);
-      _resolutionSink!.writeType(node.type);
-      _resolutionSink!.localElements.popScope();
+      resolutionSink.writeType(node.type);
+      resolutionSink.localElements.popScope();
     }
 
     _writeMarker(MarkerTag.GenericFunctionType_end);
@@ -989,13 +1016,14 @@
     _writeMarker(MarkerTag.GenericTypeAlias_typeAlias);
     _storeTypeAlias(node);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.declaredElement as TypeAliasElementImpl;
       // TODO(scheglov) pack into one byte
       _writeMarker(MarkerTag.GenericTypeAlias_flags);
-      _resolutionSink!.writeByte(element.isSimplyBounded ? 1 : 0);
-      _resolutionSink!.writeByte(element.hasSelfReference ? 1 : 0);
-      _resolutionSink!.localElements.popScope();
+      resolutionSink.writeByte(element.isSimplyBounded ? 1 : 0);
+      resolutionSink.writeByte(element.hasSelfReference ? 1 : 0);
+      resolutionSink.localElements.popScope();
     }
 
     _writeMarker(MarkerTag.GenericTypeAlias_end);
@@ -1053,10 +1081,11 @@
     _storeNamespaceDirective(node);
     _writeUInt30(resolutionIndex);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.element as ImportElementImpl;
       _writeMarker(MarkerTag.ImportDirective_importedLibrary);
-      _resolutionSink!.writeElement(element.importedLibrary);
+      resolutionSink.writeElement(element.importedLibrary);
     }
 
     _writeMarker(MarkerTag.ImportDirective_end);
@@ -1075,10 +1104,13 @@
     _writeOptionalNode(node.target);
     _writeMarker(MarkerTag.IndexExpression_index);
     _writeNode(node.index);
-    if (_shouldWriteResolution) {
+
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.IndexExpression_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
     }
+
     _writeMarker(MarkerTag.IndexExpression_expression);
     _storeExpression(node);
     _writeMarker(MarkerTag.IndexExpression_end);
@@ -1088,13 +1120,14 @@
   void visitInstanceCreationExpression(InstanceCreationExpression node) {
     _writeByte(Tag.InstanceCreationExpression);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       if (node.constructorName.name != null) {
-        _resolutionSink!.writeByte(
+        resolutionSink.writeByte(
           MethodInvocationRewriteTag.instanceCreationExpression_withName,
         );
       } else {
-        _resolutionSink!.writeByte(
+        resolutionSink.writeByte(
           MethodInvocationRewriteTag.instanceCreationExpression_withoutName,
         );
       }
@@ -1280,20 +1313,21 @@
 
     _writeUInt30(resolutionIndex);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.declaredElement as ExecutableElementImpl;
       _writeMarker(MarkerTag.MethodDeclaration_returnTypeType);
-      _writeActualReturnType(element.returnType);
+      _writeActualReturnType(resolutionSink, element.returnType);
       _writeMarker(MarkerTag.MethodDeclaration_inferenceError);
-      _writeTopLevelInferenceError(element);
+      _writeTopLevelInferenceError(resolutionSink, element);
       // TODO(scheglov) move this flag into ClassElementImpl?
       if (element is MethodElementImpl) {
         _writeMarker(MarkerTag.MethodDeclaration_flags);
-        _resolutionSink!.writeByte(
+        resolutionSink.writeByte(
           element.isOperatorEqualWithParameterTypeFromObject ? 1 : 0,
         );
       }
-      _resolutionSink!.localElements.popScope();
+      resolutionSink.localElements.popScope();
     }
 
     _writeMarker(MarkerTag.MethodDeclaration_end);
@@ -1303,8 +1337,9 @@
   void visitMethodInvocation(MethodInvocation node) {
     _writeByte(Tag.MethodInvocation);
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.writeByte(MethodInvocationRewriteTag.none);
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      resolutionSink.writeByte(MethodInvocationRewriteTag.none);
     }
 
     _writeByte(
@@ -1329,10 +1364,11 @@
 
     _writeByte(Tag.MixinDeclaration);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.declaredElement as MixinElementImpl;
-      _resolutionSink!.writeByte(element.isSimplyBounded ? 1 : 0);
-      _resolutionSink!.writeStringList(element.superInvokedNames);
+      resolutionSink.writeByte(element.isSimplyBounded ? 1 : 0);
+      resolutionSink.writeStringList(element.superInvokedNames);
     }
 
     _writeInformativeUint30(node.offset);
@@ -1356,8 +1392,8 @@
     _writeNodeList(node.members);
     _hasConstConstructor = false;
 
-    if (_shouldWriteResolution) {
-      _resolutionSink!.localElements.popScope();
+    if (resolutionSink != null) {
+      resolutionSink.localElements.popScope();
     }
 
     // TODO(scheglov) write member index
@@ -1447,18 +1483,19 @@
     var binaryToken = TokensWriter.astToBinaryTokenType(operatorToken);
     _writeByte(binaryToken.index);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.PostfixExpression_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
       if (operatorToken.isIncrementOperator) {
         _writeMarker(MarkerTag.PostfixExpression_readElement);
-        _resolutionSink!.writeElement(node.readElement);
+        resolutionSink.writeElement(node.readElement);
         _writeMarker(MarkerTag.PostfixExpression_readType);
-        _resolutionSink!.writeType(node.readType);
+        resolutionSink.writeType(node.readType);
         _writeMarker(MarkerTag.PostfixExpression_writeElement);
-        _resolutionSink!.writeElement(node.writeElement);
+        resolutionSink.writeElement(node.writeElement);
         _writeMarker(MarkerTag.PostfixExpression_writeType);
-        _resolutionSink!.writeType(node.writeType);
+        resolutionSink.writeType(node.writeType);
       }
     }
     _writeMarker(MarkerTag.PostfixExpression_expression);
@@ -1491,18 +1528,19 @@
     _writeMarker(MarkerTag.PrefixExpression_operand);
     _writeNode(node.operand);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.PrefixExpression_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
       if (operatorToken.isIncrementOperator) {
         _writeMarker(MarkerTag.PrefixExpression_readElement);
-        _resolutionSink!.writeElement(node.readElement);
+        resolutionSink.writeElement(node.readElement);
         _writeMarker(MarkerTag.PrefixExpression_readType);
-        _resolutionSink!.writeType(node.readType);
+        resolutionSink.writeType(node.readType);
         _writeMarker(MarkerTag.PrefixExpression_writeElement);
-        _resolutionSink!.writeElement(node.writeElement);
+        resolutionSink.writeElement(node.writeElement);
         _writeMarker(MarkerTag.PrefixExpression_writeType);
-        _resolutionSink!.writeType(node.writeType);
+        resolutionSink.writeType(node.writeType);
       }
     }
 
@@ -1546,10 +1584,13 @@
     _writeOptionalNode(node.constructorName);
     _writeMarker(MarkerTag.RedirectingConstructorInvocation_argumentList);
     _writeNode(node.argumentList);
-    if (_shouldWriteResolution) {
+
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.RedirectingConstructorInvocation_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
     }
+
     _writeMarker(MarkerTag.RedirectingConstructorInvocation_end);
   }
 
@@ -1563,11 +1604,12 @@
       ),
     );
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var isMapBit = node.isMap ? (1 << 0) : 0;
       var isSetBit = node.isSet ? (1 << 1) : 0;
       _writeMarker(MarkerTag.SetOrMapLiteral_flags);
-      _resolutionSink!.writeByte(isMapBit | isSetBit);
+      resolutionSink.writeByte(isMapBit | isSetBit);
     }
 
     _writeMarker(MarkerTag.SetOrMapLiteral_typeArguments);
@@ -1596,11 +1638,13 @@
     _writeMarker(MarkerTag.SimpleFormalParameter_normalFormalParameter);
     _storeNormalFormalParameter(node, node.keyword);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.declaredElement as ParameterElementImpl;
       _writeMarker(MarkerTag.SimpleFormalParameter_flags);
-      _resolutionSink!.writeByte(element.inheritsCovariant ? 1 : 0);
+      resolutionSink.writeByte(element.inheritsCovariant ? 1 : 0);
     }
+
     _writeMarker(MarkerTag.SimpleFormalParameter_end);
   }
 
@@ -1609,11 +1653,14 @@
     _writeByte(Tag.SimpleIdentifier);
     _writeStringReference(node.name);
     _writeInformativeUint30(node.offset);
-    if (_shouldWriteResolution) {
+
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.SimpleIdentifier_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
       // TODO(scheglov) It is inefficient to write many null types.
     }
+
     _writeMarker(MarkerTag.SimpleIdentifier_expression);
     _storeExpression(node);
     _writeMarker(MarkerTag.SimpleIdentifier_end);
@@ -1656,10 +1703,13 @@
     _writeOptionalNode(node.constructorName);
     _writeMarker(MarkerTag.SuperConstructorInvocation_argumentList);
     _writeNode(node.argumentList);
-    if (_shouldWriteResolution) {
+
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.SuperConstructorInvocation_staticElement);
-      _resolutionSink!.writeElement(node.staticElement);
+      resolutionSink.writeElement(node.staticElement);
     }
+
     _writeMarker(MarkerTag.SuperConstructorInvocation_end);
   }
 
@@ -1764,10 +1814,12 @@
     _writeMarker(MarkerTag.TypeName_typeArguments);
     _writeOptionalNode(node.typeArguments);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.TypeName_type);
-      _resolutionSink!.writeType(node.type);
+      resolutionSink.writeType(node.type);
     }
+
     _writeMarker(MarkerTag.TypeName_end);
   }
 
@@ -1782,15 +1834,17 @@
     _writeMarker(MarkerTag.TypeParameter_declaration);
     _storeDeclaration(node);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       var element = node.declaredElement as TypeParameterElementImpl;
       _writeMarker(MarkerTag.TypeParameter_variance);
-      _resolutionSink!.writeByte(
+      resolutionSink.writeByte(
         _encodeVariance(element),
       );
       _writeMarker(MarkerTag.TypeParameter_defaultType);
-      _resolutionSink!.writeType(element.defaultType);
+      resolutionSink.writeType(element.defaultType);
     }
+
     _writeMarker(MarkerTag.TypeParameter_end);
   }
 
@@ -1812,16 +1866,17 @@
     );
     _writeDeclarationName(node.name);
 
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       // TODO(scheglov) Enforce not null, remove `?` in `?.type` below.
       var element = node.declaredElement as VariableElementImpl;
       _writeMarker(MarkerTag.VariableDeclaration_type);
-      _writeActualType(element.type);
+      _writeActualType(resolutionSink, element.type);
       _writeMarker(MarkerTag.VariableDeclaration_inferenceError);
-      _writeTopLevelInferenceError(element);
+      _writeTopLevelInferenceError(resolutionSink, element);
       if (element is FieldElementImpl) {
         _writeMarker(MarkerTag.VariableDeclaration_inheritsCovariant);
-        _resolutionSink!.writeByte(element.inheritsCovariant ? 1 : 0);
+        resolutionSink.writeByte(element.inheritsCovariant ? 1 : 0);
       }
     }
 
@@ -1866,18 +1921,19 @@
   }
 
   void _pushScopeTypeParameters(TypeParameterList? node) {
-    if (!_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink == null) {
       return;
     }
 
-    _resolutionSink!.localElements.pushScope();
+    resolutionSink.localElements.pushScope();
 
     if (node == null) {
       return;
     }
 
     for (var typeParameter in node.typeParameters) {
-      _resolutionSink!.localElements.declare(typeParameter.declaredElement!);
+      resolutionSink.localElements.declare(typeParameter.declaredElement!);
     }
   }
 
@@ -1906,9 +1962,10 @@
   }
 
   void _storeExpression(Expression node) {
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
       _writeMarker(MarkerTag.Expression_staticType);
-      _resolutionSink!.writeType(node.staticType);
+      resolutionSink.writeType(node.staticType);
     }
   }
 
@@ -1923,9 +1980,11 @@
   void _storeForLoopParts(ForLoopParts node) {}
 
   void _storeFormalParameter(FormalParameter node) {
-    if (_shouldWriteResolution) {
+    var resolutionSink = _resolutionSink;
+    if (resolutionSink != null) {
+      var element = node.declaredElement as ParameterElementImpl;
       _writeMarker(MarkerTag.FormalParameter_type);
-      _writeActualType(node.declaredElement!.type);
+      _writeActualType(resolutionSink, element.type);
     }
   }
 
@@ -2008,14 +2067,12 @@
     _writeMarker(MarkerTag.UriBasedDirective_end);
   }
 
-  void _writeActualReturnType(DartType type) {
-    // TODO(scheglov) Check for `null` when writing resolved AST.
-    _resolutionSink!.writeType(type);
+  void _writeActualReturnType(ResolutionSink resolutionSink, DartType type) {
+    resolutionSink.writeType(type);
   }
 
-  void _writeActualType(DartType? type) {
-    // TODO(scheglov) Check for `null` when writing resolved AST.
-    _resolutionSink!.writeType(type);
+  void _writeActualType(ResolutionSink resolutionSink, DartType type) {
+    resolutionSink.writeType(type);
   }
 
   void _writeByte(int byte) {
@@ -2116,8 +2173,9 @@
 
   void _writeMarker(MarkerTag tag) {
     if (enableDebugResolutionMarkers) {
-      if (_shouldWriteResolution) {
-        _resolutionSink!.writeUInt30(tag.index);
+      var resolutionSink = _resolutionSink;
+      if (resolutionSink != null) {
+        resolutionSink.writeUInt30(tag.index);
       }
     }
   }
@@ -2156,7 +2214,10 @@
     _writeUInt30(index);
   }
 
-  void _writeTopLevelInferenceError(ElementImpl element) {
+  void _writeTopLevelInferenceError(
+    ResolutionSink resolutionSink,
+    ElementImpl element,
+  ) {
     TopLevelInferenceError? error;
     if (element is MethodElementImpl) {
       error = element.typeInferenceError;
@@ -2167,10 +2228,10 @@
     }
 
     if (error != null) {
-      _resolutionSink!.writeByte(error.kind.index);
-      _resolutionSink!.writeStringList(error.arguments);
+      resolutionSink.writeByte(error.kind.index);
+      resolutionSink.writeStringList(error.arguments);
     } else {
-      _resolutionSink!.writeByte(TopLevelInferenceErrorKind.none.index);
+      resolutionSink.writeByte(TopLevelInferenceErrorKind.none.index);
     }
   }
 
diff --git a/pkg/analyzer/lib/src/summary2/top_level_inference.dart b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
index 9832cee..77a0c47 100644
--- a/pkg/analyzer/lib/src/summary2/top_level_inference.dart
+++ b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/scope.dart';
 import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -418,7 +419,7 @@
     _resolveInitializer(forDependencies: false);
 
     if (!_elementImpl.hasTypeInferred) {
-      var initializerType = _node.initializer!.staticType!;
+      var initializerType = _node.initializer!.typeOrThrow;
       initializerType = _refineType(initializerType);
       _elementImpl.type = initializerType;
     }
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index 948dd19..a587c44 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -91,7 +91,7 @@
   }
 
   void checkAssignment(Expression expr, DartType to) {
-    checkForCast(expr, from: expr.staticType!, to: to);
+    checkForCast(expr, from: expr.typeOrThrow, to: to);
   }
 
   /// Analyzer checks boolean conversions, but we need to check too, because
@@ -116,7 +116,7 @@
       DartType expressionCastType = typeProvider.iterableDynamicType;
       checkAssignment(element.expression, expressionCastType);
 
-      var exprType = element.expression.staticType!;
+      var exprType = element.expression.typeOrThrow;
       var asIterableType = exprType.asInstanceOf(typeProvider.iterableElement);
 
       if (asIterableType != null) {
@@ -159,7 +159,7 @@
           DynamicTypeImpl.instance, DynamicTypeImpl.instance);
       checkAssignment(element.expression, expressionCastType);
 
-      var exprType = element.expression.staticType!;
+      var exprType = element.expression.typeOrThrow;
       var asMapType = exprType.asInstanceOf(typeProvider.mapElement);
 
       if (asMapType != null) {
@@ -193,7 +193,7 @@
     TokenType operatorType = operator.type;
     if (operatorType == TokenType.EQ ||
         operatorType == TokenType.QUESTION_QUESTION_EQ) {
-      checkForCast(right, from: right.staticType!, to: node.writeType!);
+      checkForCast(right, from: right.typeOrThrow, to: node.writeType!);
     } else if (operatorType == TokenType.AMPERSAND_AMPERSAND_EQ ||
         operatorType == TokenType.BAR_BAR_EQ) {
       checkBoolean(left);
@@ -376,7 +376,7 @@
         type = targs[0].type!;
       }
     } else {
-      DartType staticType = node.staticType!;
+      DartType staticType = node.typeOrThrow;
       if (staticType is InterfaceType) {
         type = staticType.typeArguments[0];
       }
@@ -449,7 +449,7 @@
           valueType = typeArguments[1].type!;
         }
       } else {
-        DartType staticType = node.staticType!;
+        DartType staticType = node.typeOrThrow;
         if (staticType is InterfaceType) {
           keyType = staticType.typeArguments[0];
         }
@@ -466,7 +466,7 @@
           type = typeArguments[0].type!;
         }
       } else {
-        DartType staticType = node.staticType!;
+        DartType staticType = node.typeOrThrow;
         if (staticType is InterfaceType) {
           type = staticType.typeArguments[0];
         }
@@ -522,7 +522,7 @@
         var initializer = variable.initializer;
         if (initializer != null) {
           checkForCast(initializer,
-              from: initializer.staticType!, to: type.type!);
+              from: initializer.typeOrThrow, to: type.type!);
         }
       }
     }
@@ -556,7 +556,7 @@
       assert(functionType.optionalParameterTypes.isEmpty);
 
       // Refine the return type.
-      var rhsType = expr.rightHandSide.staticType!;
+      var rhsType = expr.rightHandSide.typeOrThrow;
       var returnType = rules.refineBinaryExpressionType(
         expr.readType!,
         op,
@@ -947,7 +947,7 @@
     var sequenceElement = awaitKeyword != null
         ? typeProvider.streamElement
         : typeProvider.iterableElement;
-    var iterableType = node.iterable.staticType!;
+    var iterableType = node.iterable.typeOrThrow;
     var elementType = _getInstanceTypeArgument(iterableType, sequenceElement);
 
     // If the sequence is not an Iterable (or Stream for await for) but is a
diff --git a/pkg/analyzer/lib/src/util/ast_data_extractor.dart b/pkg/analyzer/lib/src/util/ast_data_extractor.dart
index 8668479..fe220d5 100644
--- a/pkg/analyzer/lib/src/util/ast_data_extractor.dart
+++ b/pkg/analyzer/lib/src/util/ast_data_extractor.dart
@@ -74,19 +74,20 @@
 
   Id createMemberId(Declaration node) {
     var element = node.declaredElement!;
-    if (element.enclosingElement is CompilationUnitElement) {
+    var enclosingElement = element.enclosingElement;
+    if (enclosingElement is CompilationUnitElement) {
       var memberName = element.name!;
       if (element is PropertyAccessorElement && element.isSetter) {
         memberName += '=';
       }
       return MemberId.internal(memberName);
-    } else if (element.enclosingElement is ClassElement) {
+    } else if (enclosingElement is ClassElement) {
       var memberName = element.name!;
-      var className = element.enclosingElement!.name;
+      var className = enclosingElement.name;
       return MemberId.internal(memberName, className: className);
-    } else if (element.enclosingElement is ExtensionElement) {
-      var memberName = element.name;
-      var extensionName = element.enclosingElement!.name;
+    } else if (enclosingElement is ExtensionElement) {
+      var memberName = element.name!;
+      var extensionName = enclosingElement.name;
       if (element is PropertyAccessorElement) {
         memberName = '${element.isGetter ? 'get' : 'set'}#$memberName';
       }
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 4237ca1..28d4f3f 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
 name: analyzer
-version: 0.42.0-nullsafety.0
+version: 1.0.0
 description: This package provides a library that performs static analysis of Dart code.
 homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
 
@@ -7,27 +7,27 @@
   sdk: '>=2.12.0-0 <3.0.0'
 
 dependencies:
-  _fe_analyzer_shared: ^15.0.0
-  args: ^2.0.0-nullsafety.0
-  cli_util: ^0.3.0-nullsafety.0
-  collection: ^1.15.0-nullsafety.5
-  convert: ^3.0.0-nullsafety.0
-  crypto: ^3.0.0-nullsafety.0
-  glob: ^2.0.0-nullsafety.0
-  meta: ^1.3.0-nullsafety.6
-  package_config: ^2.0.0-nullsafety.0
-  path: ^1.8.0-nullsafety.3
-  pub_semver: ^2.0.0-nullsafety.0
-  source_span: ^1.8.0-nullsafety.4
-  watcher: ^1.0.0-nullsafety.0
-  yaml: ^3.0.0-nullsafety.0
+  _fe_analyzer_shared: ^16.0.0
+  args: ^2.0.0
+  cli_util: ^0.3.0
+  collection: ^1.15.0
+  convert: ^3.0.0
+  crypto: ^3.0.0
+  glob: ^2.0.0
+  meta: ^1.3.0
+  package_config: ^2.0.0
+  path: ^1.8.0
+  pub_semver: ^2.0.0
+  source_span: ^1.8.0
+  watcher: ^1.0.0
+  yaml: ^3.0.0
 dev_dependencies:
   analyzer_utilities:
     path: ../analyzer_utilities
-  async: ^2.5.0-nullsafety.3
+  async: ^2.5.0
 #  linter: any
-  matcher: ^0.12.10-nullsafety.3
-  pedantic: ^1.10.0-nullsafety.3
-  test: ^1.16.0-nullsafety.13
-  test_api: ^0.2.19-nullsafety.6
-  test_reflective_loader: ^0.2.0-nullsafety.0
+  matcher: ^0.12.10
+  pedantic: ^1.10.0
+  test: ^1.16.0
+  test_api: ^0.2.19
+  test_reflective_loader: ^0.2.0
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 9ca2024..ddf271f 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -7,6 +7,7 @@
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/ast/visitor.dart';
 import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/resolver/scope.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
@@ -200,7 +201,7 @@
   void visitPrefixedIdentifier(PrefixedIdentifier node) {
     // In cases where we have a prefixed identifier where the prefix is dynamic,
     // we don't want to assert that the node will have a type.
-    if (node.staticType == null && node.prefix.staticType!.isDynamic) {
+    if (node.staticType == null && node.prefix.typeOrThrow.isDynamic) {
       return;
     }
     super.visitPrefixedIdentifier(node);
diff --git a/pkg/analyzer/test/generated/resolver_test_case.dart b/pkg/analyzer/test/generated/resolver_test_case.dart
index 2be2ffb..e4b62f1 100644
--- a/pkg/analyzer/test/generated/resolver_test_case.dart
+++ b/pkg/analyzer/test/generated/resolver_test_case.dart
@@ -295,7 +295,6 @@
   /// output.
   FunctionType expectFunctionType(String name, String type,
       {String typeParams = '[]',
-      String typeArgs = '[]',
       String typeFormals = '[]',
       String? identifierType}) {
     identifierType ??= type;
@@ -311,7 +310,6 @@
     var functionType = _getFunctionTypedElementType(identifier);
     assertType(functionType, type);
     expect(identifier.staticType, isNull);
-    expect(functionType.typeArguments.toString(), typeArgs);
     expect(typeParametersStr(functionType.typeFormals), typeFormals);
     return functionType;
   }
diff --git a/pkg/analyzer/test/generated/static_type_analyzer_test.dart b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
index 68d56a2..2144347 100644
--- a/pkg/analyzer/test/generated/static_type_analyzer_test.dart
+++ b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
@@ -8,6 +8,7 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/dart/element/type_provider.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -467,7 +468,7 @@
       _visitor.setThisInterfaceType(thisType);
     }
     node.accept(_analyzer);
-    return node.staticType!;
+    return node.typeOrThrow;
   }
 
   void _assertType(
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index 5954810..304b425 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -6,6 +6,7 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/nullability_suffix.dart';
 import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test/test.dart';
@@ -124,9 +125,9 @@
             (body as BlockFunctionBody).block.statements[0] as ReturnStatement;
         returnExp = stmt.expression!;
       }
-      DartType type = returnExp.staticType!;
+      DartType type = returnExp.typeOrThrow;
       if (returnExp is AwaitExpression) {
-        type = returnExp.expression.staticType!;
+        type = returnExp.expression.typeOrThrow;
       }
       typeTest(type as InterfaceType);
     }
@@ -179,9 +180,9 @@
             (body as BlockFunctionBody).block.statements[0] as ReturnStatement;
         returnExp = stmt.expression!;
       }
-      DartType type = returnExp.staticType!;
+      DartType type = returnExp.typeOrThrow;
       if (returnExp is AwaitExpression) {
-        type = returnExp.expression.staticType!;
+        type = returnExp.expression.typeOrThrow;
       }
       typeTest(type as InterfaceType);
     }
@@ -226,7 +227,7 @@
     Element elementA = AstFinder.getClass(unit, "A").declaredElement!;
 
     CascadeExpression cascade = fetch(0);
-    _isInstantiationOf(_hasElement(elementA))([_isInt])(cascade.staticType!);
+    _isInstantiationOf(_hasElement(elementA))([_isInt])(cascade.typeOrThrow);
     var invoke = cascade.cascadeSections[0] as MethodInvocation;
     var function = invoke.argumentList.arguments[1] as FunctionExpression;
     ExecutableElement f0 = function.declaredElement!;
@@ -251,7 +252,7 @@
     var stmt = statements[0] as VariableDeclarationStatement;
     VariableDeclaration decl = stmt.variables.variables[0];
     Expression call = decl.initializer!;
-    _isInt(call.staticType!);
+    _isInt(call.typeOrThrow);
   }
 
   test_constrainedByBounds2() async {
@@ -271,7 +272,7 @@
     var stmt = statements[0] as VariableDeclarationStatement;
     VariableDeclaration decl = stmt.variables.variables[0];
     Expression call = decl.initializer!;
-    _isInt(call.staticType!);
+    _isInt(call.typeOrThrow);
   }
 
   test_constrainedByBounds3() async {
@@ -288,7 +289,7 @@
     var stmt = statements[0] as VariableDeclarationStatement;
     VariableDeclaration decl = stmt.variables.variables[0];
     Expression call = decl.initializer!;
-    _isInt(call.staticType!);
+    _isInt(call.typeOrThrow);
   }
 
   test_constrainedByBounds4() async {
@@ -310,7 +311,7 @@
     var stmt = statements[0] as VariableDeclarationStatement;
     VariableDeclaration decl = stmt.variables.variables[0];
     Expression call = decl.initializer!;
-    _isInt(call.staticType!);
+    _isInt(call.typeOrThrow);
   }
 
   test_constrainedByBounds5() async {
@@ -334,7 +335,7 @@
     var stmt = statements[0] as VariableDeclarationStatement;
     VariableDeclaration decl = stmt.variables.variables[0];
     Expression call = decl.initializer!;
-    _isDynamic(call.staticType!);
+    _isDynamic(call.typeOrThrow);
   }
 
   test_constructorInitializer_propagation() async {
@@ -375,7 +376,7 @@
     _isInstantiationOf(_hasElement(elementB))([
       _isType(elementA.typeParameters[0]
           .instantiate(nullabilitySuffix: NullabilitySuffix.star))
-    ])(exp.staticType!);
+    ])(exp.typeOrThrow);
   }
 
   test_fieldDeclaration_propagation() async {
@@ -953,7 +954,7 @@
     FutureOr<List<int>> test() => mk(3);
     ''');
     _isListOf(_isInt)(invoke.staticType as InterfaceType);
-    _isInt(invoke.argumentList.arguments[0].staticType!);
+    _isInt(invoke.argumentList.arguments[0].typeOrThrow);
   }
 
   test_futureOr_methods1() async {
@@ -961,7 +962,7 @@
     MethodInvocation invoke = await _testFutureOr(r'''
     dynamic test(FutureOr<int> x) => x.toString();
     ''');
-    _isString(invoke.staticType!);
+    _isString(invoke.typeOrThrow);
   }
 
   test_futureOr_methods2() async {
@@ -971,7 +972,7 @@
     ''', expectedErrors: [
       error(CompileTimeErrorCode.UNDEFINED_METHOD, 61, 3),
     ]);
-    _isDynamic(invoke.staticType!);
+    _isDynamic(invoke.typeOrThrow);
   }
 
   test_futureOr_methods3() async {
@@ -981,7 +982,7 @@
     ''', expectedErrors: [
       error(CompileTimeErrorCode.UNDEFINED_METHOD, 61, 4),
     ]);
-    _isDynamic(invoke.staticType!);
+    _isDynamic(invoke.typeOrThrow);
   }
 
   test_futureOr_methods4() async {
@@ -991,7 +992,7 @@
     ''', expectedErrors: [
       error(CompileTimeErrorCode.UNDEFINED_METHOD, 65, 3),
     ]);
-    _isDynamic(invoke.staticType!);
+    _isDynamic(invoke.typeOrThrow);
   }
 
   test_futureOr_no_return() async {
@@ -1001,7 +1002,7 @@
     test() => f.then((int x) {});
     ''');
     _isFunction2Of(_isInt, _isNull)(
-        invoke.argumentList.arguments[0].staticType!);
+        invoke.argumentList.arguments[0].typeOrThrow);
     _isFutureOfNull(invoke.staticType as InterfaceType);
   }
 
@@ -1012,7 +1013,7 @@
     test() => f.then((int x) {return;});
     ''');
     _isFunction2Of(_isInt, _isNull)(
-        invoke.argumentList.arguments[0].staticType!);
+        invoke.argumentList.arguments[0].typeOrThrow);
     _isFutureOfNull(invoke.staticType as InterfaceType);
   }
 
@@ -1023,7 +1024,7 @@
     test() => f.then((int x) {return null;});
     ''');
     _isFunction2Of(_isInt, _isNull)(
-        invoke.argumentList.arguments[0].staticType!);
+        invoke.argumentList.arguments[0].typeOrThrow);
     _isFutureOfNull(invoke.staticType as InterfaceType);
   }
 
@@ -1056,7 +1057,7 @@
     test() => f.then<Null>((int x) {});
     ''');
     _isFunction2Of(_isInt, _isNull)(
-        invoke.argumentList.arguments[0].staticType!);
+        invoke.argumentList.arguments[0].typeOrThrow);
     _isFutureOfNull(invoke.staticType as InterfaceType);
   }
 
@@ -1067,7 +1068,7 @@
     test() => f.then<Null>((int x) {return;});
     ''');
     _isFunction2Of(_isInt, _isNull)(
-        invoke.argumentList.arguments[0].staticType!);
+        invoke.argumentList.arguments[0].typeOrThrow);
     _isFutureOfNull(invoke.staticType as InterfaceType);
   }
 
@@ -1078,7 +1079,7 @@
     test() => f.then<Null>((int x) { return null;});
     ''');
     _isFunction2Of(_isInt, _isNull)(
-        invoke.argumentList.arguments[0].staticType!);
+        invoke.argumentList.arguments[0].typeOrThrow);
     _isFutureOfNull(invoke.staticType as InterfaceType);
   }
 
@@ -1124,7 +1125,7 @@
       var stmt = statements[i] as VariableDeclarationStatement;
       VariableDeclaration decl = stmt.variables.variables[0];
       Expression init = decl.initializer!;
-      _isInstantiationOf(_hasElement(elementA))([_isInt])(init.staticType!);
+      _isInstantiationOf(_hasElement(elementA))([_isInt])(init.typeOrThrow);
     }
 
     for (var i = 0; i < 5; i++) {
@@ -1664,7 +1665,7 @@
     }
 
     void hasType(Asserter<DartType> assertion, Expression exp) =>
-        assertion(exp.staticType!);
+        assertion(exp.typeOrThrow);
 
     Element elementA = AstFinder.getClass(unit, "A").declaredElement!;
     Element elementB = AstFinder.getClass(unit, "B").declaredElement!;
@@ -1858,7 +1859,7 @@
       var stmt = statements[i] as VariableDeclarationStatement;
       VariableDeclaration decl = stmt.variables.variables[0];
       var exp = decl.initializer as ListLiteral;
-      return exp.staticType!;
+      return exp.typeOrThrow;
     }
 
     Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt);
@@ -1893,7 +1894,7 @@
       var stmt = statements[i] as VariableDeclarationStatement;
       VariableDeclaration decl = stmt.variables.variables[0];
       var exp = decl.initializer as ListLiteral;
-      return exp.staticType!;
+      return exp.typeOrThrow;
     }
 
     Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt);
@@ -1930,7 +1931,7 @@
       var stmt = statements[i] as VariableDeclarationStatement;
       VariableDeclaration decl = stmt.variables.variables[0];
       var exp = decl.initializer as ListLiteral;
-      return exp.staticType!;
+      return exp.typeOrThrow;
     }
 
     _isListOf(_isNum)(literal(0) as InterfaceType);
@@ -2149,7 +2150,7 @@
 
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
-    _isString(body.expression.staticType!);
+    _isString(body.expression.typeOrThrow);
     var invoke = body.expression as MethodInvocation;
     var function = invoke.argumentList.arguments[0] as FunctionExpression;
     ExecutableElement f0 = function.declaredElement!;
@@ -2175,7 +2176,7 @@
 
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
-    DartType type = body.expression.staticType!;
+    DartType type = body.expression.typeOrThrow;
 
     Element elementB = AstFinder.getClass(unit, "B").declaredElement!;
 
@@ -2197,7 +2198,7 @@
 
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
-    DartType type = body.expression.staticType!;
+    DartType type = body.expression.typeOrThrow;
 
     Element elementB = AstFinder.getClass(unit, "B").declaredElement!;
 
@@ -2222,7 +2223,7 @@
 
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
-    DartType type = body.expression.staticType!;
+    DartType type = body.expression.typeOrThrow;
 
     Element elementB = AstFinder.getClass(unit, "B").declaredElement!;
 
@@ -2245,7 +2246,7 @@
 
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
-    DartType type = body.expression.staticType!;
+    DartType type = body.expression.typeOrThrow;
 
     Element elementB = AstFinder.getClass(unit, "B").declaredElement!;
 
@@ -2519,7 +2520,7 @@
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
     var call = body.expression as MethodInvocation;
-    _isNum(call.staticType!);
+    _isNum(call.typeOrThrow);
     _isFunction2Of(_isFunction2Of(_isNum, _isString), _isNum)(
         call.staticInvokeType!);
   }
@@ -2538,7 +2539,7 @@
     FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test");
     var body = test.functionExpression.body as ExpressionFunctionBody;
     var call = body.expression as MethodInvocation;
-    _isNum(call.staticType!);
+    _isNum(call.typeOrThrow);
     _isFunction2Of(_isFunction2Of(_isString, _isNum), _isNum)(
         call.staticInvokeType!);
   }
@@ -3176,8 +3177,6 @@
 ''');
     MethodInvocation f = findNode.methodInvocation('f<int>(3);');
     assertInvokeType(f, 'S Function(int)');
-    var ft = f.staticInvokeType as FunctionType;
-    expect('${ft.typeArguments}', '[S, int]');
 
     expectIdentifierType('f;', 'S Function<Sâ‚€ extends S>(Sâ‚€)');
   }
diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart
index 2ef1bb7..23ee17b 100644
--- a/pkg/analyzer/test/generated/utilities_test.dart
+++ b/pkg/analyzer/test/generated/utilities_test.dart
@@ -7,7 +7,6 @@
 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
 import 'package:analyzer/dart/ast/token.dart';
 import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/source/line_info.dart';
 import 'package:analyzer/src/dart/ast/token.dart';
 import 'package:analyzer/src/dart/ast/utilities.dart';
 import 'package:analyzer/src/dart/scanner/reader.dart';
diff --git a/pkg/analyzer/test/id_tests/nullability_test.dart b/pkg/analyzer/test/id_tests/nullability_test.dart
index 6b98e40..c74f028 100644
--- a/pkg/analyzer/test/id_tests/nullability_test.dart
+++ b/pkg/analyzer/test/id_tests/nullability_test.dart
@@ -12,6 +12,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/analysis/testing_data.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart';
 import 'package:analyzer/src/util/ast_data_extractor.dart';
 import 'package:test/test.dart';
@@ -94,11 +95,11 @@
     if (parent is AssignmentExpression && parent.leftHandSide == node) {
       return parent.readType!;
     } else if (parent is PostfixExpression) {
-      return parent.readType ?? node.staticType!;
+      return parent.readType ?? node.typeOrThrow;
     } else if (parent is PrefixExpression) {
-      return parent.readType ?? node.staticType!;
+      return parent.readType ?? node.typeOrThrow;
     } else {
-      return node.staticType!;
+      return node.typeOrThrow;
     }
   }
 }
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index de3eeed..e6d0d18 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -9,6 +9,7 @@
 import 'package:analyzer/dart/element/nullability_suffix.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/src/dart/analysis/experiments.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/member.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -5553,7 +5554,7 @@
     var fooInvocation = fooStatement.expression as MethodInvocation;
     assertInvokeType(fooInvocation, 'T Function(C<T>)');
     assertType(fooInvocation.staticType, 'T');
-    expect(fooInvocation.staticType!.element, same(tElement));
+    expect(fooInvocation.typeOrThrow.element, same(tElement));
   }
 
   test_methodInvocation_topLevelFunction() async {
@@ -8287,7 +8288,7 @@
 
     SimpleIdentifier name = invocation.methodName;
     expect(name.staticElement, isNull);
-    assertUnresolvedInvokeType(name.staticType!);
+    assertUnresolvedInvokeType(name.typeOrThrow);
 
     assertTypeArguments(invocation.typeArguments!, [intType, doubleType]);
     _assertInvocationArguments(invocation.argumentList,
@@ -8314,7 +8315,7 @@
 
     SimpleIdentifier name = invocation.methodName;
     assertElementNull(name);
-    assertUnresolvedInvokeType(name.staticType!);
+    assertUnresolvedInvokeType(name.typeOrThrow);
 
     assertTypeArguments(invocation.typeArguments!, [intType, doubleType]);
     _assertInvocationArguments(invocation.argumentList,
diff --git a/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart b/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
index 9805e89f..0552496 100644
--- a/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
@@ -14,7 +14,6 @@
     defineReflectiveTests(IsConstantTypeExpressionTest);
     defineReflectiveTests(IsPotentiallyConstantTypeExpressionTest);
     defineReflectiveTests(PotentiallyConstantTest);
-    defineReflectiveTests(PotentiallyConstantWithNonFunctionTypeAliasesTest);
     defineReflectiveTests(PotentiallyConstantWithoutNullSafetyTest);
   });
 }
@@ -212,6 +211,17 @@
 ''', () => _xInitializer());
   }
 
+  test_asExpression_typeParameter_nested() async {
+    await _assertConst(r'''
+const a = 0;
+class A<T> {
+  m() {
+    var x = a as List<T>;
+  }
+}
+''', () => _xInitializer());
+  }
+
   test_conditional() async {
     await _assertConst(r'''
 const a = 0;
@@ -308,6 +318,17 @@
 ''', () => _xInitializer());
   }
 
+  test_isExpression_typeParameter_nested() async {
+    await _assertConst(r'''
+const a = 0;
+class A<T> {
+  m() {
+    var x = a is List<T>;
+  }
+}
+''', () => _xInitializer());
+  }
+
   test_listLiteral() async {
     await _assertConst(r'''
 var x = const [0, 1, 2];
@@ -603,6 +624,16 @@
     );
   }
 
+  test_prefixedIdentifier_typedef_interfaceType() async {
+    newFile('$testPackageLibPath/a.dart', content: r'''
+typedef A = List<int>;
+''');
+    await _assertConst(r'''
+import 'a.dart' as p;
+var x = p.A;
+''', () => _xInitializer());
+  }
+
   test_prefixExpression_bang() async {
     await _assertConst(r'''
 const a = 0;
@@ -859,6 +890,13 @@
 ''', () => _xInitializer());
   }
 
+  test_simpleIdentifier_typedef_interfaceType() async {
+    await _assertConst(r'''
+typedef A = List<int>;
+var x = A;
+''', () => _xInitializer());
+  }
+
   test_spreadElement() async {
     await _assertConst(r'''
 const a = [0, 1, 2];
@@ -925,75 +963,6 @@
   }
 }
 
-/// TODO(https://github.com/dart-lang/sdk/issues/44666): Combine this class
-/// with the one it extends.
-@reflectiveTest
-class PotentiallyConstantWithNonFunctionTypeAliasesTest
-    extends PotentiallyConstantTest {
-  @override
-  test_asExpression_typeParameter() async {
-    await _assertConst(r'''
-const a = 0;
-class A<T> {
-  m() {
-    var x = a as T;
-  }
-}
-''', () => _xInitializer());
-  }
-
-  test_asExpression_typeParameter_nested() async {
-    await _assertConst(r'''
-const a = 0;
-class A<T> {
-  m() {
-    var x = a as List<T>;
-  }
-}
-''', () => _xInitializer());
-  }
-
-  @override
-  test_isExpression_typeParameter() async {
-    await _assertConst(r'''
-const a = 0;
-class A<T> {
-  m() {
-    var x = a is T;
-  }
-}
-''', () => _xInitializer());
-  }
-
-  test_isExpression_typeParameter_nested() async {
-    await _assertConst(r'''
-const a = 0;
-class A<T> {
-  m() {
-    var x = a is List<T>;
-  }
-}
-''', () => _xInitializer());
-  }
-
-  test_prefixedIdentifier_typedef_interfaceType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
-typedef A = List<int>;
-''');
-    await _assertConst(r'''
-import 'a.dart' as p;
-var x = p.A;
-''', () => _xInitializer());
-  }
-
-  test_simpleIdentifier_typedef_interfaceType() async {
-    await _assertConst(r'''
-typedef A = List<int>;
-var x = A;
-''', () => _xInitializer());
-  }
-}
-
 @reflectiveTest
 class PotentiallyConstantWithoutNullSafetyTest extends PubPackageResolutionTest
     with WithoutNullSafetyMixin {
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 66aa3e5..03658e3 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -1460,7 +1460,6 @@
     MethodElement method = typeAI.getMethod(methodName)!;
     expect(method, isNotNull);
     FunctionType methodType = method.type;
-    expect(methodType.typeArguments, isEmpty);
     expect(methodType.returnType, same(typeI));
     List<DartType> parameterTypes = methodType.normalParameterTypes;
     expect(parameterTypes, hasLength(1));
diff --git a/pkg/analyzer/test/src/dart/element/function_type_test.dart b/pkg/analyzer/test/src/dart/element/function_type_test.dart
index 7fffdbf..79cf038 100644
--- a/pkg/analyzer/test/src/dart/element/function_type_test.dart
+++ b/pkg/analyzer/test/src/dart/element/function_type_test.dart
@@ -37,8 +37,7 @@
   InterfaceType get objectType => typeProvider.objectType;
 
   void basicChecks(FunctionType f,
-      {element,
-      displayName = 'dynamic Function()',
+      {displayName = 'dynamic Function()',
       returnType,
       namedParameterTypes = isEmpty,
       normalParameterNames = isEmpty,
@@ -47,7 +46,6 @@
       optionalParameterTypes = isEmpty,
       parameters = isEmpty,
       typeFormals = isEmpty,
-      typeArguments = isEmpty,
       typeParameters = isEmpty}) {
     // DartType properties
     expect(
@@ -55,9 +53,6 @@
       displayName,
       reason: 'displayName',
     );
-    expect(f.element, element, reason: 'element');
-    // ParameterizedType properties
-    expect(f.typeArguments, typeArguments, reason: 'typeArguments');
     // FunctionType properties
     expect(f.namedParameterTypes, namedParameterTypes,
         reason: 'namedParameterTypes');
@@ -274,7 +269,7 @@
       returnType: dynamicType,
       nullabilitySuffix: NullabilitySuffix.star,
     );
-    basicChecks(f, element: isNull);
+    basicChecks(f);
   }
 
   test_synthetic_instantiate() {
@@ -289,7 +284,6 @@
     );
     FunctionType instantiated = f.instantiate([objectType]);
     basicChecks(instantiated,
-        element: isNull,
         displayName: 'Object Function(Object)',
         returnType: same(objectType),
         normalParameterNames: ['x'],
@@ -328,7 +322,6 @@
       nullabilitySuffix: NullabilitySuffix.star,
     );
     basicChecks(f,
-        element: isNull,
         displayName: 'dynamic Function({Object x})',
         namedParameterTypes: {'x': same(objectType)},
         parameters: hasLength(1));
@@ -346,7 +339,6 @@
       nullabilitySuffix: NullabilitySuffix.star,
     );
     basicChecks(f,
-        element: isNull,
         displayName: 'dynamic Function(Object)',
         normalParameterNames: ['x'],
         normalParameterTypes: [same(objectType)],
@@ -365,7 +357,6 @@
       nullabilitySuffix: NullabilitySuffix.star,
     );
     basicChecks(f,
-        element: isNull,
         displayName: 'dynamic Function([Object])',
         optionalParameterNames: ['x'],
         optionalParameterTypes: [same(objectType)],
@@ -383,9 +374,7 @@
       nullabilitySuffix: NullabilitySuffix.star,
     );
     basicChecks(f,
-        element: isNull,
-        displayName: 'Object Function()',
-        returnType: same(objectType));
+        displayName: 'Object Function()', returnType: same(objectType));
   }
 
   test_synthetic_typeFormals() {
@@ -397,7 +386,6 @@
       nullabilitySuffix: NullabilitySuffix.star,
     );
     basicChecks(f,
-        element: isNull,
         displayName: 'T Function<T>()',
         returnType: typeParameterTypeStar(t),
         typeFormals: [same(t)]);
diff --git a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
index 3b6e492..87b8431 100644
--- a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
@@ -12,9 +12,6 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(AssignmentDriverResolutionTest);
-    defineReflectiveTests(
-      AssignmentDriverResolutionWithNonFunctionTypeAliasesTest,
-    );
   });
 }
 
@@ -863,6 +860,42 @@
     assertType(assignment.rightHandSide, 'int');
   }
 
+  test_prefixedIdentifier_typeAlias_static_compound() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  static int get x => 0;
+  static set x(int _) {}
+}
+
+typedef B = A;
+
+void f() {
+  B.x += 2;
+}
+''');
+
+    var assignment = findNode.assignment('x += 2');
+    assertAssignment(
+      assignment,
+      readElement: findElement.getter('x'),
+      readType: 'int',
+      writeElement: findElement.setter('x'),
+      writeType: 'int',
+      operatorElement: elementMatcher(
+        numElement.getMethod('+'),
+        isLegacy: isNullSafetySdkAndLegacyLibrary,
+      ),
+      type: 'int',
+    );
+
+    var prefixed = assignment.leftHandSide as PrefixedIdentifier;
+    assertSimpleIdentifierAssignmentTarget(
+      prefixed.identifier,
+    );
+
+    assertType(assignment.rightHandSide, 'int');
+  }
+
   test_prefixedIdentifier_unresolved1_simple() async {
     await assertErrorsInCode(r'''
 void f(int c) {
@@ -2384,45 +2417,3 @@
     );
   }
 }
-
-/// TODO(https://github.com/dart-lang/sdk/issues/44666): Combine this class
-/// with the one above.
-@reflectiveTest
-class AssignmentDriverResolutionWithNonFunctionTypeAliasesTest
-    extends PubPackageResolutionTest {
-  test_prefixedIdentifier_typeAlias_static_compound() async {
-    await assertNoErrorsInCode(r'''
-class A {
-  static int get x => 0;
-  static set x(int _) {}
-}
-
-typedef B = A;
-
-void f() {
-  B.x += 2;
-}
-''');
-
-    var assignment = findNode.assignment('x += 2');
-    assertAssignment(
-      assignment,
-      readElement: findElement.getter('x'),
-      readType: 'int',
-      writeElement: findElement.setter('x'),
-      writeType: 'int',
-      operatorElement: elementMatcher(
-        numElement.getMethod('+'),
-        isLegacy: isNullSafetySdkAndLegacyLibrary,
-      ),
-      type: 'int',
-    );
-
-    var prefixed = assignment.leftHandSide as PrefixedIdentifier;
-    assertSimpleIdentifierAssignmentTarget(
-      prefixed.identifier,
-    );
-
-    assertType(assignment.rightHandSide, 'int');
-  }
-}
diff --git a/pkg/analyzer/test/src/dart/resolution/constant_test.dart b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
index 5ee85c3..994999d 100644
--- a/pkg/analyzer/test/src/dart/resolution/constant_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
@@ -133,13 +133,7 @@
     // The element and type arguments are available for the function type.
     var importFind = findElement.importFind('package:test/a.dart');
     var alias = importFind.typeAlias('F');
-    expect(typeArgument.aliasElement, alias);
-    assertElementTypeStrings(typeArgument.aliasArguments, ['double']);
-
-    // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
-    expect(typeArgument.element, alias.aliasedElement);
-    expect(typeArgument.element!.enclosingElement, alias);
-    assertElementTypeStrings(typeArgument.typeArguments, ['double']);
+    assertTypeAlias(typeArgument, element: alias, typeArguments: ['double']);
   }
 
   test_imported_prefixedIdentifier_staticField_class() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/function_type_alias_test.dart b/pkg/analyzer/test/src/dart/resolution/function_type_alias_test.dart
index 38d3b3d..127b2e8 100644
--- a/pkg/analyzer/test/src/dart/resolution/function_type_alias_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/function_type_alias_test.dart
@@ -2,9 +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/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
-import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'context_collection_resolution.dart';
@@ -25,16 +23,10 @@
 ''');
     var type = findElement.topVar('g').type as FunctionType;
     assertType(type, 'int Function()');
-
-    var typedefG = findElement.typeAlias('G');
-    var functionG = typedefG.aliasedElement as GenericFunctionTypeElement;
-
-    expect(type.aliasElement, typedefG);
-    assertElementTypeStrings(type.aliasArguments, ['int']);
-
-    // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
-    expect(type.element, functionG);
-    expect(type.element?.enclosingElement, typedefG);
-    assertElementTypeStrings(type.typeArguments, ['int']);
+    assertTypeAlias(
+      type,
+      element: findElement.typeAlias('G'),
+      typeArguments: ['int'],
+    );
   }
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart b/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
index d048c4b..99c2406 100644
--- a/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
@@ -150,17 +150,11 @@
 ''');
     var type = findElement.topVar('g').type as FunctionType;
     assertType(type, 'int Function(double)?');
-
-    var typedefG = findElement.typeAlias('G');
-    var functionG = typedefG.aliasedElement as GenericFunctionTypeElement;
-
-    expect(type.aliasElement, typedefG);
-    assertElementTypeStrings(type.aliasArguments, ['int']);
-
-    // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
-    expect(type.element, functionG);
-    expect(type.element?.enclosingElement, typedefG);
-    assertElementTypeStrings(type.typeArguments, ['int']);
+    assertTypeAlias(
+      type,
+      element: findElement.typeAlias('G'),
+      typeArguments: ['int'],
+    );
   }
 
   test_typeParameters() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 78d48cf..5b351a0 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/error/error.dart';
 import 'package:analyzer/src/dart/analysis/feature_set_provider.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/member.dart';
 import 'package:analyzer/src/dart/element/type.dart';
@@ -339,24 +340,6 @@
     assertType(node, type);
   }
 
-  /// We have a contract with the Angular team that FunctionType(s) from
-  /// typedefs carry the element of the typedef, and the type arguments.
-  void assertFunctionTypeTypedef(
-    FunctionType type, {
-    required FunctionTypeAliasElement element,
-    required List<String> typeArguments,
-  }) {
-    assertElement2(type.aliasElement, declaration: element);
-    assertElementTypeStrings(type.aliasArguments, typeArguments);
-
-    // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
-    assertElement2(
-      type.element,
-      declaration: element.aliasedElement as GenericFunctionTypeElement,
-    );
-    assertElementTypeStrings(type.typeArguments, typeArguments);
-  }
-
   void assertHasTestErrors() {
     expect(result.errors, isNotEmpty);
   }
@@ -758,6 +741,28 @@
     }
   }
 
+  /// We have a contract with the Angular team that FunctionType(s) from
+  /// typedefs carry the element of the typedef, and the type arguments.
+  void assertTypeAlias(
+    DartType type, {
+    required TypeAliasElement element,
+    required List<String> typeArguments,
+  }) {
+    assertElement2(type.aliasElement, declaration: element);
+    assertElementTypeStrings(type.aliasArguments, typeArguments);
+
+    // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
+    if (type is FunctionType) {
+      assertElement2(
+        // ignore: deprecated_member_use_from_same_package
+        type.element,
+        declaration: element.aliasedElement as GenericFunctionTypeElement,
+      );
+      // ignore: deprecated_member_use_from_same_package
+      assertElementTypeStrings(type.typeArguments, typeArguments);
+    }
+  }
+
   /// Assert that the given [identifier] is a reference to a type alias, in the
   /// form that is not a separate expression, e.g. in a static method
   /// invocation like `C.staticMethod()`, or a type annotation `C c = null`.
@@ -789,7 +794,7 @@
 
   void assertTypeLegacy(Expression? expression) {
     expression!;
-    NullabilitySuffix actual = expression.staticType!.nullabilitySuffix;
+    NullabilitySuffix actual = expression.typeOrThrow.nullabilitySuffix;
     expect(actual, NullabilitySuffix.star);
   }
 
diff --git a/pkg/analyzer/test/src/dart/resolution/type_name_test.dart b/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
index bdd17d5..89086df 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_name_test.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.
 
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/type.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';
@@ -616,9 +614,9 @@
     var typeName = findNode.typeName('F a');
     assertTypeName(typeName, element, 'int* Function(bool*)*');
 
-    assertFunctionTypeTypedef(
-      typeName.type as FunctionType,
-      element: element as FunctionTypeAliasElement,
+    assertTypeAlias(
+      typeName.type!,
+      element: element,
       typeArguments: [],
     );
   }
@@ -640,9 +638,9 @@
     var typeName = findNode.typeName('F a');
     assertTypeName(typeName, element, 'dynamic Function(bool*)*');
 
-    assertFunctionTypeTypedef(
-      typeName.type as FunctionType,
-      element: element as FunctionTypeAliasElement,
+    assertTypeAlias(
+      typeName.type!,
+      element: element,
       typeArguments: ['dynamic'],
     );
   }
@@ -664,9 +662,9 @@
     var typeName = findNode.typeName('F a');
     assertTypeName(typeName, element, 'num* Function(bool*)*');
 
-    assertFunctionTypeTypedef(
-      typeName.type as FunctionType,
-      element: element as FunctionTypeAliasElement,
+    assertTypeAlias(
+      typeName.type!,
+      element: element,
       typeArguments: ['num*'],
     );
   }
@@ -688,9 +686,9 @@
     var typeName = findNode.typeName('F<int> a');
     assertTypeName(typeName, element, 'int* Function(bool*)*');
 
-    assertFunctionTypeTypedef(
-      typeName.type as FunctionType,
-      element: element as FunctionTypeAliasElement,
+    assertTypeAlias(
+      typeName.type!,
+      element: element,
       typeArguments: ['int*'],
     );
   }
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
index fc6fd7c..a61776f 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
@@ -10,14 +10,73 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(UndefinedOperatorTest);
+    defineReflectiveTests(UndefinedOperatorWithoutNullSafetyTest);
   });
 }
 
 @reflectiveTest
 class UndefinedOperatorTest extends PubPackageResolutionTest
-    with WithoutNullSafetyMixin {
-  // TODO(https://github.com/dart-lang/sdk/issues/44666): Use null safety in
-  //  test cases.
+    with UndefinedOperatorTestCases {
+  test_postfixExpression() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    a++;
+  }
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 43, 2),
+    ]);
+  }
+
+  test_postfixExpression_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator +(B b) {return new B();}
+}
+f(var a) {
+  if (a is A) {
+    a++;
+  }
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 101, 2),
+    ]);
+  }
+
+  test_prefixExpression() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    ++a;
+  }
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 42, 2),
+    ]);
+  }
+
+  test_prefixExpression_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator +(B b) {return new B();}
+}
+f(var a) {
+  if (a is A) {
+    ++a;
+  }
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 100, 2),
+    ]);
+  }
+}
+
+mixin UndefinedOperatorTestCases on PubPackageResolutionTest {
   test_assignmentExpression_undefined() async {
     await assertErrorsInCode(r'''
 class A {}
@@ -171,16 +230,6 @@
     ]);
   }
 
-  test_index_null() async {
-    await assertErrorsInCode(r'''
-f(Null x) {
-  x[0];
-}
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 15, 3),
-    ]);
-  }
-
   test_index_set_extendedHasGetter_extensionHasSetter() async {
     await assertErrorsInCode(r'''
 class A {
@@ -259,6 +308,82 @@
     ]);
   }
 
+  test_plus_undefined() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(A a) {
+  a + 1;
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 24, 1),
+    ]);
+  }
+
+  test_postfixExpression_mixin() async {
+    await assertErrorsInCode(r'''
+mixin M {}
+f(M m) {
+  m++;
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 23, 2),
+    ]);
+  }
+
+  test_postfixExpression_undefined() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(A a) {
+  a++;
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 23, 2),
+    ]);
+  }
+
+  test_prefixExpression_mixin() async {
+    await assertErrorsInCode(r'''
+mixin M {}
+f(M m) {
+  -m;
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 22, 1),
+    ]);
+  }
+
+  test_prefixExpression_undefined() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(A a) {
+  ++a;
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 22, 2),
+    ]);
+  }
+
+  test_tilde_defined() async {
+    await assertNoErrorsInCode(r'''
+const A = 3;
+const B = ~((1 << A) - 1);
+''');
+  }
+}
+
+@reflectiveTest
+class UndefinedOperatorWithoutNullSafetyTest extends PubPackageResolutionTest
+    with UndefinedOperatorTestCases, WithoutNullSafetyMixin {
+  test_index_null() async {
+    await assertErrorsInCode(r'''
+f(Null x) {
+  x[0];
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 15, 3),
+    ]);
+  }
+
   test_minus_null() async {
     await assertErrorsInCode(r'''
 m() {
@@ -293,17 +418,6 @@
     ]);
   }
 
-  test_plus_undefined() async {
-    await assertErrorsInCode(r'''
-class A {}
-f(A a) {
-  a + 1;
-}
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 24, 1),
-    ]);
-  }
-
   test_plusEq_null() async {
     await assertErrorsInCode(r'''
 m() {
@@ -353,28 +467,6 @@
 ''');
   }
 
-  test_postfixExpression_mixin() async {
-    await assertErrorsInCode(r'''
-mixin M {}
-f(M m) {
-  m++;
-}
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 23, 2),
-    ]);
-  }
-
-  test_postfixExpression_undefined() async {
-    await assertErrorsInCode(r'''
-class A {}
-f(A a) {
-  a++;
-}
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 23, 2),
-    ]);
-  }
-
   test_postfixInc_null() async {
     await assertErrorsInCode(r'''
 m() {
@@ -400,7 +492,7 @@
   }
 
   test_prefixExpression() async {
-    await assertNoErrorsInCode(r'''
+    await assertNoErrorsInCode('''
 class A {}
 f(var a) {
   if (a is A) {
@@ -411,7 +503,7 @@
   }
 
   test_prefixExpression_inSubtype() async {
-    await assertNoErrorsInCode(r'''
+    await assertNoErrorsInCode('''
 class A {}
 class B extends A {
   operator +(B b) {return new B();}
@@ -424,30 +516,8 @@
 ''');
   }
 
-  test_prefixExpression_mixin() async {
-    await assertErrorsInCode(r'''
-mixin M {}
-f(M m) {
-  -m;
-}
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 22, 1),
-    ]);
-  }
-
-  test_prefixExpression_undefined() async {
-    await assertErrorsInCode(r'''
-class A {}
-f(A a) {
-  ++a;
-}
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_OPERATOR, 22, 2),
-    ]);
-  }
-
   test_prefixInc_null() async {
-    await assertErrorsInCode(r'''
+    await assertErrorsInCode('''
 m() {
   Null x;
   ++x;
@@ -458,15 +528,8 @@
     ]);
   }
 
-  test_tilde_defined() async {
-    await assertNoErrorsInCode(r'''
-const A = 3;
-const B = ~((1 << A) - 1);
-''');
-  }
-
   test_unaryMinus_null() async {
-    await assertErrorsInCode(r'''
+    await assertErrorsInCode('''
 m() {
   Null x;
   -x;
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 2ed4e8f..b10e93f 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -7446,10 +7446,6 @@
 
     expect(type.aliasElement, same(unit.typeAliases[0]));
     _assertTypeStrings(type.aliasArguments!, ['int']);
-
-    // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
-    expect(type.element!.enclosingElement, same(unit.typeAliases[0]));
-    _assertTypeStrings(type.typeArguments, ['int']);
   }
 
   test_functionTypeAlias_typeParameters_variance_contravariant() async {
diff --git a/pkg/analyzer/tool/summary/generate.dart b/pkg/analyzer/tool/summary/generate.dart
index cc515a9..2c495ae 100644
--- a/pkg/analyzer/tool/summary/generate.dart
+++ b/pkg/analyzer/tool/summary/generate.dart
@@ -19,7 +19,6 @@
 import 'dart:io';
 
 import 'package:_fe_analyzer_shared/src/scanner/scanner.dart';
-import 'package:_fe_analyzer_shared/src/scanner/token.dart' show Token;
 import 'package:analyzer_utilities/tools.dart';
 
 import 'idl_model.dart' as idl_model;
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index eb831fc..362f6ac 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -1061,9 +1061,17 @@
   /// that is locally visible. Otherwise, return `null`.
   DartType _getVisibleType(DartType type,
       {ExecutableElement methodBeingCopied}) {
-    var element = type.element;
+    if (type is InterfaceType) {
+      var element = type.element;
+      if (element.isPrivate &&
+          !dartFileEditBuilder._isDefinedLocally(element)) {
+        return null;
+      }
+      return type;
+    }
     if (type is TypeParameterType) {
       _initializeEnclosingElements();
+      var element = type.element;
       var enclosing = element.enclosingElement;
       while (enclosing is GenericFunctionTypeElement ||
           enclosing is ParameterElement) {
@@ -1076,12 +1084,6 @@
       }
       return null;
     }
-    if (element == null) {
-      return type;
-    }
-    if (element.isPrivate && !dartFileEditBuilder._isDefinedLocally(element)) {
-      return null;
-    }
     return type;
   }
 
diff --git a/pkg/dartdev/lib/src/commands/analyze.dart b/pkg/dartdev/lib/src/commands/analyze.dart
index 5e533f4..5018dee 100644
--- a/pkg/dartdev/lib/src/commands/analyze.dart
+++ b/pkg/dartdev/lib/src/commands/analyze.dart
@@ -177,7 +177,7 @@
     for (final AnalysisError error in errors) {
       // error • Message ... at path.dart:line:col • (code)
 
-      var filePath = path.relative(error.file, from: relativeToDir?.path);
+      var filePath = _relativePath(error.file, relativeToDir?.path);
       var severity = error.severity.toLowerCase().padLeft(_severityWidth);
       if (error.isError) {
         severity = log.ansi.error(severity);
@@ -192,10 +192,13 @@
 
       if (verbose) {
         for (var message in error.contextMessages) {
+          var contextPath = _relativePath(error.file, relativeToDir?.path);
+          var messageSentenceFragment = trimEnd(message.message, '.');
+
           // Wrap longer context messages.
           var contextMessage = wrapText(
-              '${message.message} at '
-              '${message.filePath}:${message.line}:${message.column}',
+              '$messageSentenceFragment at '
+              '$contextPath:${message.line}:${message.column}',
               width: wrapWidth);
           log.stdout('$_bodyIndent'
               '${contextMessage.replaceAll('\n', '\n$_bodyIndent')}');
@@ -222,6 +225,12 @@
     log.stdout('$errorCount ${pluralize('issue', errorCount)} found.');
   }
 
+  /// Return a relative path if it is a shorter reference than the given path.
+  static String _relativePath(String givenPath, String fromPath) {
+    String relative = path.relative(givenPath, from: fromPath);
+    return relative.length <= givenPath.length ? relative : givenPath;
+  }
+
   @visibleForTesting
   static void emitMachineFormat(Logger log, List<AnalysisError> errors) {
     for (final AnalysisError error in errors) {
diff --git a/pkg/dartdev/test/commands/analyze_test.dart b/pkg/dartdev/test/commands/analyze_test.dart
index f2d9895..722951e 100644
--- a/pkg/dartdev/test/commands/analyze_test.dart
+++ b/pkg/dartdev/test/commands/analyze_test.dart
@@ -195,7 +195,7 @@
     expect(result.exitCode, 3);
     expect(result.stderr, isEmpty);
     var stdout = result.stdout;
-    expect(stdout, contains("The declaration of 'one' is on line 3."));
+    expect(stdout, contains("The declaration of 'one' is on line 3 at "));
     expect(
         stdout, contains('Try moving the declaration to before the first use'));
     expect(
diff --git a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
index d7aa824..020a579 100644
--- a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
+++ b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
@@ -15,9 +15,9 @@
 import 'package:kernel/ast.dart' show Component, Library;
 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
 import 'package:kernel/class_hierarchy.dart';
-import 'package:kernel/target/targets.dart' show TargetFlags;
 import 'package:kernel/src/tool/find_referenced_libraries.dart'
     show duplicateLibrariesReachable;
+import 'package:kernel/target/targets.dart' show TargetFlags;
 import 'package:meta/meta.dart';
 import 'package:vm/http_filesystem.dart';
 
@@ -422,6 +422,7 @@
     // instead on expression evaluation.
     // TODO(annagrin): throw on load failures when blaze build starts
     // producing all summaries.
+    var futures = <Future>[];
     for (var input in request.inputs) {
       // Support older debugger versions that do not provide summary
       // path by loading full dill kernel instead.
@@ -432,11 +433,11 @@
                 ' Loading full dill instead.');
       }
       var summaryPath = input.summaryPath ?? input.path;
-      await _loadAndUpdateComponent(
-          Uri.parse(summaryPath), input.moduleName, hasSummary);
-
       _fullModules[input.moduleName] = Uri.parse(input.path);
+      futures.add(_loadAndUpdateComponent(
+          Uri.parse(summaryPath), input.moduleName, hasSummary));
     }
+    await Future.wait(futures);
 
     _processedOptions.ticker
         .logMs('Updated dependencies for expression evaluation');
diff --git a/pkg/kernel/lib/core_types.dart b/pkg/kernel/lib/core_types.dart
index 7c9a566..9fa6f5a 100644
--- a/pkg/kernel/lib/core_types.dart
+++ b/pkg/kernel/lib/core_types.dart
@@ -2,14 +2,13 @@
 // 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.9
-
 library kernel.core_types;
 
-import 'package:kernel/type_algebra.dart';
-
+// ignore: import_of_legacy_library_into_null_safe
 import 'ast.dart';
 import 'library_index.dart';
+// ignore: import_of_legacy_library_into_null_safe
+import 'type_algebra.dart';
 
 /// Provides access to the classes and libraries in the core libraries.
 class CoreTypes {
@@ -45,135 +44,67 @@
 
   final LibraryIndex index;
 
-  Library _coreLibrary;
-  Class _objectClass;
-  Class _deprecatedNullClass;
-  Class _boolClass;
-  Class _intClass;
-  Class _numClass;
-  Class _doubleClass;
-  Class _stringClass;
-  Class _listClass;
-  Class _setClass;
-  Class _mapClass;
-  Class _iterableClass;
-  Class _iteratorClass;
-  Class _symbolClass;
-  Class _typeClass;
-  Class _functionClass;
-  Class _invocationClass;
-  Class _invocationMirrorClass;
-  Constructor _invocationMirrorWithTypeConstructor;
-  Constructor _noSuchMethodErrorDefaultConstructor;
-  Procedure _listDefaultConstructor;
-  Procedure _listFromConstructor;
-  Procedure _listUnmodifiableConstructor;
-  Procedure _identicalProcedure;
-  Constructor _fallThroughErrorUrlAndLineConstructor;
-  Procedure _objectEquals;
-  Procedure _mapUnmodifiable;
-  Procedure _iterableGetIterator;
-  Procedure _iteratorMoveNext;
-  Procedure _iteratorGetCurrent;
-  Procedure _isSentinelMethod;
-  Procedure _createSentinelMethod;
-
-  Class _internalSymbolClass;
-
-  Library _asyncLibrary;
-  Class _futureClass;
-  Class _deprecatedFutureOrClass;
-  Class _stackTraceClass;
-  Class _streamClass;
-  Class _futureImplClass;
-  Constructor _futureImplConstructor;
-  Procedure _completeOnAsyncErrorProcedure;
-  Procedure _completeOnAsyncReturnProcedure;
-  Constructor _syncIterableDefaultConstructor;
-  Constructor _streamIteratorDefaultConstructor;
-  Constructor _asyncStarStreamControllerDefaultConstructor;
-  Procedure _asyncStarMoveNextHelperProcedure;
-  Procedure _asyncThenWrapperHelperProcedure;
-  Procedure _asyncErrorWrapperHelperProcedure;
-  Procedure _awaitHelperProcedure;
-  Procedure _boolFromEnvironment;
-  Constructor _lateInitializationFieldAssignedDuringInitializationConstructor;
-  Constructor _lateInitializationLocalAssignedDuringInitializationConstructor;
-  Constructor _lateInitializationFieldNotInitializedConstructor;
-  Constructor _lateInitializationLocalNotInitializedConstructor;
-  Constructor _lateInitializationFieldAlreadyInitializedConstructor;
-  Constructor _lateInitializationLocalAlreadyInitializedConstructor;
-  Constructor _reachabilityErrorConstructor;
-
-  /// The `dart:mirrors` library, or `null` if the component does not use it.
-  Library _mirrorsLibrary;
-
-  Class _pragmaClass;
-  Field _pragmaName;
-  Field _pragmaOptions;
-  Constructor _pragmaConstructor;
-
-  InterfaceType _objectLegacyRawType;
-  InterfaceType _objectNullableRawType;
-  InterfaceType _objectNonNullableRawType;
-  InterfaceType _deprecatedNullType;
-  InterfaceType _boolLegacyRawType;
-  InterfaceType _boolNullableRawType;
-  InterfaceType _boolNonNullableRawType;
-  InterfaceType _intLegacyRawType;
-  InterfaceType _intNullableRawType;
-  InterfaceType _intNonNullableRawType;
-  InterfaceType _numLegacyRawType;
-  InterfaceType _numNullableRawType;
-  InterfaceType _numNonNullableRawType;
-  InterfaceType _doubleLegacyRawType;
-  InterfaceType _doubleNullableRawType;
-  InterfaceType _doubleNonNullableRawType;
-  InterfaceType _stringLegacyRawType;
-  InterfaceType _stringNullableRawType;
-  InterfaceType _stringNonNullableRawType;
-  InterfaceType _listLegacyRawType;
-  InterfaceType _listNullableRawType;
-  InterfaceType _listNonNullableRawType;
-  InterfaceType _setLegacyRawType;
-  InterfaceType _setNullableRawType;
-  InterfaceType _setNonNullableRawType;
-  InterfaceType _mapLegacyRawType;
-  InterfaceType _mapNullableRawType;
-  InterfaceType _mapNonNullableRawType;
-  InterfaceType _iterableLegacyRawType;
-  InterfaceType _iterableNullableRawType;
-  InterfaceType _iterableNonNullableRawType;
-  InterfaceType _iteratorLegacyRawType;
-  InterfaceType _iteratorNullableRawType;
-  InterfaceType _iteratorNonNullableRawType;
-  InterfaceType _symbolLegacyRawType;
-  InterfaceType _symbolNullableRawType;
-  InterfaceType _symbolNonNullableRawType;
-  InterfaceType _typeLegacyRawType;
-  InterfaceType _typeNullableRawType;
-  InterfaceType _typeNonNullableRawType;
-  InterfaceType _functionLegacyRawType;
-  InterfaceType _functionNullableRawType;
-  InterfaceType _functionNonNullableRawType;
-  InterfaceType _invocationLegacyRawType;
-  InterfaceType _invocationNullableRawType;
-  InterfaceType _invocationNonNullableRawType;
-  InterfaceType _invocationMirrorLegacyRawType;
-  InterfaceType _invocationMirrorNullableRawType;
-  InterfaceType _invocationMirrorNonNullableRawType;
-  InterfaceType _futureLegacyRawType;
-  InterfaceType _futureNullableRawType;
-  InterfaceType _futureNonNullableRawType;
-  InterfaceType _stackTraceLegacyRawType;
-  InterfaceType _stackTraceNullableRawType;
-  InterfaceType _stackTraceNonNullableRawType;
-  InterfaceType _streamLegacyRawType;
-  InterfaceType _streamNullableRawType;
-  InterfaceType _streamNonNullableRawType;
-  InterfaceType _pragmaLegacyRawType;
-  InterfaceType _pragmaNullableRawType;
-  InterfaceType _pragmaNonNullableRawType;
+  InterfaceType? _objectLegacyRawType;
+  InterfaceType? _objectNullableRawType;
+  InterfaceType? _objectNonNullableRawType;
+  InterfaceType? _deprecatedNullType;
+  InterfaceType? _boolLegacyRawType;
+  InterfaceType? _boolNullableRawType;
+  InterfaceType? _boolNonNullableRawType;
+  InterfaceType? _intLegacyRawType;
+  InterfaceType? _intNullableRawType;
+  InterfaceType? _intNonNullableRawType;
+  InterfaceType? _numLegacyRawType;
+  InterfaceType? _numNullableRawType;
+  InterfaceType? _numNonNullableRawType;
+  InterfaceType? _doubleLegacyRawType;
+  InterfaceType? _doubleNullableRawType;
+  InterfaceType? _doubleNonNullableRawType;
+  InterfaceType? _stringLegacyRawType;
+  InterfaceType? _stringNullableRawType;
+  InterfaceType? _stringNonNullableRawType;
+  InterfaceType? _listLegacyRawType;
+  InterfaceType? _listNullableRawType;
+  InterfaceType? _listNonNullableRawType;
+  InterfaceType? _setLegacyRawType;
+  InterfaceType? _setNullableRawType;
+  InterfaceType? _setNonNullableRawType;
+  InterfaceType? _mapLegacyRawType;
+  InterfaceType? _mapNullableRawType;
+  InterfaceType? _mapNonNullableRawType;
+  InterfaceType? _iterableLegacyRawType;
+  InterfaceType? _iterableNullableRawType;
+  InterfaceType? _iterableNonNullableRawType;
+  InterfaceType? _iteratorLegacyRawType;
+  InterfaceType? _iteratorNullableRawType;
+  InterfaceType? _iteratorNonNullableRawType;
+  InterfaceType? _symbolLegacyRawType;
+  InterfaceType? _symbolNullableRawType;
+  InterfaceType? _symbolNonNullableRawType;
+  InterfaceType? _typeLegacyRawType;
+  InterfaceType? _typeNullableRawType;
+  InterfaceType? _typeNonNullableRawType;
+  InterfaceType? _functionLegacyRawType;
+  InterfaceType? _functionNullableRawType;
+  InterfaceType? _functionNonNullableRawType;
+  InterfaceType? _invocationLegacyRawType;
+  InterfaceType? _invocationNullableRawType;
+  InterfaceType? _invocationNonNullableRawType;
+  InterfaceType? _invocationMirrorLegacyRawType;
+  InterfaceType? _invocationMirrorNullableRawType;
+  InterfaceType? _invocationMirrorNonNullableRawType;
+  InterfaceType? _futureLegacyRawType;
+  InterfaceType? _futureNullableRawType;
+  InterfaceType? _futureNonNullableRawType;
+  InterfaceType? _stackTraceLegacyRawType;
+  InterfaceType? _stackTraceNullableRawType;
+  InterfaceType? _stackTraceNonNullableRawType;
+  InterfaceType? _streamLegacyRawType;
+  InterfaceType? _streamNullableRawType;
+  InterfaceType? _streamNonNullableRawType;
+  InterfaceType? _pragmaLegacyRawType;
+  InterfaceType? _pragmaNullableRawType;
+  InterfaceType? _pragmaNonNullableRawType;
   final Map<Class, InterfaceType> _legacyRawTypes =
       new Map<Class, InterfaceType>.identity();
   final Map<Class, InterfaceType> _nullableRawTypes =
@@ -190,311 +121,192 @@
   CoreTypes(Component component)
       : index = new LibraryIndex.coreLibraries(component);
 
-  Procedure get asyncErrorWrapperHelperProcedure {
-    return _asyncErrorWrapperHelperProcedure ??=
-        index.getTopLevelMember('dart:async', '_asyncErrorWrapperHelper');
-  }
+  late final Procedure asyncErrorWrapperHelperProcedure = index
+      .getTopLevelMember('dart:async', '_asyncErrorWrapperHelper') as Procedure;
 
-  Library get asyncLibrary {
-    return _asyncLibrary ??= index.getLibrary('dart:async');
-  }
+  late final Library asyncLibrary = index.getLibrary('dart:async');
 
-  Member get asyncStarStreamControllerAdd {
-    return index.getMember('dart:async', '_AsyncStarStreamController', 'add');
-  }
+  late final Member asyncStarStreamControllerAdd =
+      index.getMember('dart:async', '_AsyncStarStreamController', 'add');
 
-  Member get asyncStarStreamControllerAddError {
-    return index.getMember(
-        'dart:async', '_AsyncStarStreamController', 'addError');
-  }
+  late final Member asyncStarStreamControllerAddError =
+      index.getMember('dart:async', '_AsyncStarStreamController', 'addError');
 
-  Member get asyncStarStreamControllerAddStream {
-    return index.getMember(
-        'dart:async', '_AsyncStarStreamController', 'addStream');
-  }
+  late final Member asyncStarStreamControllerAddStream =
+      index.getMember('dart:async', '_AsyncStarStreamController', 'addStream');
 
-  Class get asyncStarStreamControllerClass {
-    return index.getClass('dart:async', '_AsyncStarStreamController');
-  }
+  late final Class asyncStarStreamControllerClass =
+      index.getClass('dart:async', '_AsyncStarStreamController');
 
-  Member get asyncStarStreamControllerClose {
-    return index.getMember('dart:async', '_AsyncStarStreamController', 'close');
-  }
+  late final Member asyncStarStreamControllerClose =
+      index.getMember('dart:async', '_AsyncStarStreamController', 'close');
 
-  Constructor get asyncStarStreamControllerDefaultConstructor {
-    return _asyncStarStreamControllerDefaultConstructor ??=
-        index.getMember('dart:async', '_AsyncStarStreamController', '');
-  }
+  late final Constructor asyncStarStreamControllerDefaultConstructor = index
+      .getMember('dart:async', '_AsyncStarStreamController', '') as Constructor;
 
-  Member get asyncStarStreamControllerStream {
-    return index.getMember(
-        'dart:async', '_AsyncStarStreamController', 'get:stream');
-  }
+  late final Member asyncStarStreamControllerStream =
+      index.getMember('dart:async', '_AsyncStarStreamController', 'get:stream');
 
-  Procedure get asyncStarMoveNextHelper {
-    return _asyncStarMoveNextHelperProcedure ??=
-        index.getTopLevelMember('dart:async', '_asyncStarMoveNextHelper');
-  }
+  late final Procedure asyncStarMoveNextHelper = index.getTopLevelMember(
+      'dart:async', '_asyncStarMoveNextHelper') as Procedure;
 
-  Procedure get asyncThenWrapperHelperProcedure {
-    return _asyncThenWrapperHelperProcedure ??=
-        index.getTopLevelMember('dart:async', '_asyncThenWrapperHelper');
-  }
+  late final Procedure asyncThenWrapperHelperProcedure = index
+      .getTopLevelMember('dart:async', '_asyncThenWrapperHelper') as Procedure;
 
-  Procedure get awaitHelperProcedure {
-    return _awaitHelperProcedure ??=
-        index.getTopLevelMember('dart:async', '_awaitHelper');
-  }
+  late final Procedure awaitHelperProcedure =
+      index.getTopLevelMember('dart:async', '_awaitHelper') as Procedure;
 
-  Class get boolClass {
-    return _boolClass ??= index.getClass('dart:core', 'bool');
-  }
+  late final Class boolClass = index.getClass('dart:core', 'bool');
 
-  Class get futureImplClass {
-    return _futureImplClass ??= index.getClass('dart:async', '_Future');
-  }
+  late final Class futureImplClass = index.getClass('dart:async', '_Future');
 
-  Constructor get futureImplConstructor {
-    return _futureImplConstructor ??=
-        index.getMember('dart:async', '_Future', '');
-  }
+  late final Constructor futureImplConstructor =
+      index.getMember('dart:async', '_Future', '') as Constructor;
 
-  Member get completeOnAsyncReturn {
-    return _completeOnAsyncReturnProcedure ??=
-        index.getTopLevelMember('dart:async', '_completeOnAsyncReturn');
-  }
+  late final Member completeOnAsyncReturn =
+      index.getTopLevelMember('dart:async', '_completeOnAsyncReturn');
 
-  Member get completeOnAsyncError {
-    return _completeOnAsyncErrorProcedure ??=
-        index.getTopLevelMember('dart:async', '_completeOnAsyncError');
-  }
+  late final Member completeOnAsyncError =
+      index.getTopLevelMember('dart:async', '_completeOnAsyncError');
 
-  Library get coreLibrary {
-    return _coreLibrary ??= index.getLibrary('dart:core');
-  }
+  late final Library coreLibrary = index.getLibrary('dart:core');
 
-  Class get doubleClass {
-    return _doubleClass ??= index.getClass('dart:core', 'double');
-  }
+  late final Class doubleClass = index.getClass('dart:core', 'double');
 
-  Class get functionClass {
-    return _functionClass ??= index.getClass('dart:core', 'Function');
-  }
+  late final Class functionClass = index.getClass('dart:core', 'Function');
 
-  Class get futureClass {
-    return _futureClass ??= index.getClass('dart:core', 'Future');
-  }
+  late final Class futureClass = index.getClass('dart:core', 'Future');
 
   // TODO(dmitryas): Remove it when FutureOrType is fully supported.
-  Class get deprecatedFutureOrClass {
-    return _deprecatedFutureOrClass ??=
-        index.getClass('dart:async', 'FutureOr');
-  }
+  late final Class deprecatedFutureOrClass =
+      index.getClass('dart:async', 'FutureOr');
 
-  Procedure get identicalProcedure {
-    return _identicalProcedure ??=
-        index.getTopLevelMember('dart:core', 'identical');
-  }
+  late final Procedure identicalProcedure =
+      index.getTopLevelMember('dart:core', 'identical') as Procedure;
 
-  Class get intClass {
-    return _intClass ??= index.getClass('dart:core', 'int');
-  }
+  late final Class intClass = index.getClass('dart:core', 'int');
 
-  Class get internalSymbolClass {
-    return _internalSymbolClass ??= index.getClass('dart:_internal', 'Symbol');
-  }
+  late final Class internalSymbolClass =
+      index.getClass('dart:_internal', 'Symbol');
 
-  Class get invocationClass {
-    return _invocationClass ??= index.getClass('dart:core', 'Invocation');
-  }
+  late final Class invocationClass = index.getClass('dart:core', 'Invocation');
 
-  Class get invocationMirrorClass {
-    return _invocationMirrorClass ??=
-        index.getClass('dart:core', '_InvocationMirror');
-  }
+  late final Class invocationMirrorClass =
+      index.getClass('dart:core', '_InvocationMirror');
 
-  Constructor get invocationMirrorWithTypeConstructor {
-    return _invocationMirrorWithTypeConstructor ??=
-        index.getMember('dart:core', '_InvocationMirror', '_withType');
-  }
+  late final Constructor invocationMirrorWithTypeConstructor = index.getMember(
+      'dart:core', '_InvocationMirror', '_withType') as Constructor;
 
-  Class get iterableClass {
-    return _iterableClass ??= index.getClass('dart:core', 'Iterable');
-  }
+  late final Class iterableClass = index.getClass('dart:core', 'Iterable');
 
-  Procedure get iterableGetIterator {
-    return _iterableGetIterator ??=
-        index.getMember('dart:core', 'Iterable', 'get:iterator');
-  }
+  late final Procedure iterableGetIterator =
+      index.getMember('dart:core', 'Iterable', 'get:iterator') as Procedure;
 
-  Class get iteratorClass {
-    return _iteratorClass ??= index.getClass('dart:core', 'Iterator');
-  }
+  late final Class iteratorClass = index.getClass('dart:core', 'Iterator');
 
-  Procedure get iteratorMoveNext {
-    return _iteratorMoveNext ??=
-        index.getMember('dart:core', 'Iterator', 'moveNext');
-  }
+  late final Procedure iteratorMoveNext =
+      index.getMember('dart:core', 'Iterator', 'moveNext') as Procedure;
 
-  Procedure get iteratorGetCurrent {
-    return _iteratorGetCurrent ??=
-        index.getMember('dart:core', 'Iterator', 'get:current');
-  }
+  late final Procedure iteratorGetCurrent =
+      index.getMember('dart:core', 'Iterator', 'get:current') as Procedure;
 
-  Class get listClass {
-    return _listClass ??= index.getClass('dart:core', 'List');
-  }
+  late final Class listClass = index.getClass('dart:core', 'List');
 
-  Procedure get listDefaultConstructor {
-    return _listDefaultConstructor ??= index.getMember('dart:core', 'List', '');
-  }
+  late final Procedure listDefaultConstructor =
+      index.getMember('dart:core', 'List', '') as Procedure;
 
-  Procedure get listFromConstructor {
-    return _listFromConstructor ??=
-        index.getMember('dart:core', 'List', 'from');
-  }
+  late final Procedure listFromConstructor =
+      index.getMember('dart:core', 'List', 'from') as Procedure;
 
-  Procedure get listUnmodifiableConstructor {
-    return _listUnmodifiableConstructor ??=
-        index.getMember('dart:core', 'List', 'unmodifiable');
-  }
+  late final Procedure listUnmodifiableConstructor =
+      index.getMember('dart:core', 'List', 'unmodifiable') as Procedure;
 
-  Class get setClass {
-    return _setClass ??= index.getClass('dart:core', 'Set');
-  }
+  late final Class setClass = index.getClass('dart:core', 'Set');
 
-  Class get mapClass {
-    return _mapClass ??= index.getClass('dart:core', 'Map');
-  }
+  late final Class mapClass = index.getClass('dart:core', 'Map');
 
-  Procedure get mapUnmodifiable {
-    return _mapUnmodifiable ??=
-        index.getMember('dart:core', 'Map', 'unmodifiable');
-  }
+  late final Procedure mapUnmodifiable =
+      index.getMember('dart:core', 'Map', 'unmodifiable') as Procedure;
 
-  Library get mirrorsLibrary {
-    return _mirrorsLibrary ??= index.tryGetLibrary('dart:mirrors');
-  }
+  /// The `dart:mirrors` library, or `null` if the component does not use it.
+  late final Library? mirrorsLibrary = index.tryGetLibrary('dart:mirrors');
 
-  Constructor get noSuchMethodErrorDefaultConstructor {
-    return _noSuchMethodErrorDefaultConstructor ??=
-        // TODO(regis): Replace 'withInvocation' with '' after dart2js is fixed.
-        index.getMember('dart:core', 'NoSuchMethodError', 'withInvocation');
-  }
+  late final Constructor noSuchMethodErrorDefaultConstructor =
+      // TODO(regis): Replace 'withInvocation' with '' after dart2js is fixed.
+      index.getMember('dart:core', 'NoSuchMethodError', 'withInvocation')
+          as Constructor;
 
-  Class get deprecatedNullClass {
-    return _deprecatedNullClass ??= index.getClass('dart:core', 'Null');
-  }
+  late final Class deprecatedNullClass = index.getClass('dart:core', 'Null');
 
-  Class get numClass {
-    return _numClass ??= index.getClass('dart:core', 'num');
-  }
+  late final Class numClass = index.getClass('dart:core', 'num');
 
-  Class get objectClass {
-    return _objectClass ??= index.getClass('dart:core', 'Object');
-  }
+  late final Class objectClass = index.getClass('dart:core', 'Object');
 
-  Procedure get objectEquals {
-    return _objectEquals ??= index.getMember('dart:core', 'Object', '==');
-  }
+  late final Procedure objectEquals =
+      index.getMember('dart:core', 'Object', '==') as Procedure;
 
-  Class get pragmaClass {
-    return _pragmaClass ??= index.getClass('dart:core', 'pragma');
-  }
+  late final Class pragmaClass = index.getClass('dart:core', 'pragma');
 
-  Field get pragmaName {
-    return _pragmaName ??= index.getMember('dart:core', 'pragma', 'name');
-  }
+  late final Field pragmaName =
+      index.getMember('dart:core', 'pragma', 'name') as Field;
 
-  Field get pragmaOptions {
-    return _pragmaOptions ??= index.getMember('dart:core', 'pragma', 'options');
-  }
+  late final Field pragmaOptions =
+      index.getMember('dart:core', 'pragma', 'options') as Field;
 
-  Constructor get pragmaConstructor {
-    return _pragmaConstructor ??= index.getMember('dart:core', 'pragma', '_');
-  }
+  late final Constructor pragmaConstructor =
+      index.getMember('dart:core', 'pragma', '_') as Constructor;
 
-  Class get stackTraceClass {
-    return _stackTraceClass ??= index.getClass('dart:core', 'StackTrace');
-  }
+  late final Class stackTraceClass = index.getClass('dart:core', 'StackTrace');
 
-  Class get streamClass {
-    return _streamClass ??= index.getClass('dart:core', 'Stream');
-  }
+  late final Class streamClass = index.getClass('dart:core', 'Stream');
 
-  Member get streamIteratorSubscription {
-    return index.getMember('dart:async', '_StreamIterator', '_subscription');
-  }
+  late final Member streamIteratorSubscription =
+      index.getMember('dart:async', '_StreamIterator', '_subscription');
 
-  Member get streamIteratorCancel {
-    return index.getMember('dart:async', '_StreamIterator', 'cancel');
-  }
+  late final Member streamIteratorCancel =
+      index.getMember('dart:async', '_StreamIterator', 'cancel');
 
-  Class get streamIteratorClass {
-    return index.getClass('dart:async', '_StreamIterator');
-  }
+  late final Class streamIteratorClass =
+      index.getClass('dart:async', '_StreamIterator');
 
-  Constructor get streamIteratorDefaultConstructor {
-    return _streamIteratorDefaultConstructor ??=
-        index.getMember('dart:async', '_StreamIterator', '');
-  }
+  late final Constructor streamIteratorDefaultConstructor =
+      index.getMember('dart:async', '_StreamIterator', '') as Constructor;
 
-  Member get streamIteratorMoveNext {
-    return index.getMember('dart:async', '_StreamIterator', 'moveNext');
-  }
+  late final Member streamIteratorMoveNext =
+      index.getMember('dart:async', '_StreamIterator', 'moveNext');
 
-  Member get streamIteratorCurrent {
-    return index.getMember('dart:async', '_StreamIterator', 'get:current');
-  }
+  late final Member streamIteratorCurrent =
+      index.getMember('dart:async', '_StreamIterator', 'get:current');
 
-  Class get stringClass {
-    return _stringClass ??= index.getClass('dart:core', 'String');
-  }
+  late final Class stringClass = index.getClass('dart:core', 'String');
 
-  Class get symbolClass {
-    return _symbolClass ??= index.getClass('dart:core', 'Symbol');
-  }
+  late final Class symbolClass = index.getClass('dart:core', 'Symbol');
 
-  Constructor get syncIterableDefaultConstructor {
-    return _syncIterableDefaultConstructor ??=
-        index.getMember('dart:core', '_SyncIterable', '');
-  }
+  late final Constructor syncIterableDefaultConstructor =
+      index.getMember('dart:core', '_SyncIterable', '') as Constructor;
 
-  Class get syncIteratorClass {
-    return index.getClass('dart:core', '_SyncIterator');
-  }
+  late final Class syncIteratorClass =
+      index.getClass('dart:core', '_SyncIterator');
 
-  Member get syncIteratorCurrent {
-    return index.getMember('dart:core', '_SyncIterator', '_current');
-  }
+  late final Member syncIteratorCurrent =
+      index.getMember('dart:core', '_SyncIterator', '_current');
 
-  Member get syncIteratorYieldEachIterable {
-    return index.getMember('dart:core', '_SyncIterator', '_yieldEachIterable');
-  }
+  late final Member syncIteratorYieldEachIterable =
+      index.getMember('dart:core', '_SyncIterator', '_yieldEachIterable');
 
-  Class get typeClass {
-    return _typeClass ??= index.getClass('dart:core', 'Type');
-  }
+  late final Class typeClass = index.getClass('dart:core', 'Type');
 
-  Constructor get fallThroughErrorUrlAndLineConstructor {
-    return _fallThroughErrorUrlAndLineConstructor ??=
-        index.getMember('dart:core', 'FallThroughError', '_create');
-  }
+  late final Constructor fallThroughErrorUrlAndLineConstructor = index
+      .getMember('dart:core', 'FallThroughError', '_create') as Constructor;
 
-  Procedure get boolFromEnvironment {
-    return _boolFromEnvironment ??=
-        index.getMember('dart:core', 'bool', 'fromEnvironment');
-  }
+  late final Procedure boolFromEnvironment =
+      index.getMember('dart:core', 'bool', 'fromEnvironment') as Procedure;
 
-  Procedure get createSentinelMethod {
-    return _createSentinelMethod ??=
-        index.getTopLevelMember('dart:_internal', 'createSentinel');
-  }
+  late final Procedure createSentinelMethod =
+      index.getTopLevelMember('dart:_internal', 'createSentinel') as Procedure;
 
-  Procedure get isSentinelMethod {
-    return _isSentinelMethod ??=
-        index.getTopLevelMember('dart:_internal', 'isSentinel');
-  }
+  late final Procedure isSentinelMethod =
+      index.getTopLevelMember('dart:_internal', 'isSentinel') as Procedure;
 
   InterfaceType get objectLegacyRawType {
     return _objectLegacyRawType ??= _legacyRawTypes[objectClass] ??=
@@ -1193,7 +1005,7 @@
   }
 
   InterfaceType thisInterfaceType(Class klass, Nullability nullability) {
-    InterfaceType result = _thisInterfaceTypes[klass];
+    InterfaceType? result = _thisInterfaceTypes[klass];
     if (result == null) {
       return _thisInterfaceTypes[klass] = new InterfaceType(klass, nullability,
           getAsTypeArguments(klass.typeParameters, klass.enclosingLibrary));
@@ -1206,7 +1018,7 @@
   }
 
   TypedefType thisTypedefType(Typedef typedef, Nullability nullability) {
-    TypedefType result = _thisTypedefTypes[typedef];
+    TypedefType? result = _thisTypedefTypes[typedef];
     if (result == null) {
       return _thisTypedefTypes[typedef] = new TypedefType(typedef, nullability,
           getAsTypeArguments(typedef.typeParameters, typedef.enclosingLibrary));
@@ -1218,45 +1030,31 @@
     return result;
   }
 
-  Constructor
-      get lateInitializationFieldAssignedDuringInitializationConstructor {
-    return _lateInitializationFieldAssignedDuringInitializationConstructor ??=
-        index.getMember('dart:_internal', 'LateError', 'fieldADI');
-  }
+  late final Constructor
+      lateInitializationFieldAssignedDuringInitializationConstructor =
+      index.getMember('dart:_internal', 'LateError', 'fieldADI') as Constructor;
 
-  Constructor
-      get lateInitializationLocalAssignedDuringInitializationConstructor {
-    return _lateInitializationLocalAssignedDuringInitializationConstructor ??=
-        index.getMember('dart:_internal', 'LateError', 'localADI');
-  }
+  late final Constructor
+      lateInitializationLocalAssignedDuringInitializationConstructor =
+      index.getMember('dart:_internal', 'LateError', 'localADI') as Constructor;
 
-  Constructor get lateInitializationFieldNotInitializedConstructor {
-    return _lateInitializationFieldNotInitializedConstructor ??=
-        index.getMember('dart:_internal', 'LateError', 'fieldNI');
-  }
+  late final Constructor lateInitializationFieldNotInitializedConstructor =
+      index.getMember('dart:_internal', 'LateError', 'fieldNI') as Constructor;
 
-  Constructor get lateInitializationLocalNotInitializedConstructor {
-    return _lateInitializationLocalNotInitializedConstructor ??=
-        index.getMember('dart:_internal', 'LateError', 'localNI');
-  }
+  late final Constructor lateInitializationLocalNotInitializedConstructor =
+      index.getMember('dart:_internal', 'LateError', 'localNI') as Constructor;
 
-  Constructor get lateInitializationFieldAlreadyInitializedConstructor {
-    return _lateInitializationFieldAlreadyInitializedConstructor ??=
-        index.getMember('dart:_internal', 'LateError', 'fieldAI');
-  }
+  late final Constructor lateInitializationFieldAlreadyInitializedConstructor =
+      index.getMember('dart:_internal', 'LateError', 'fieldAI') as Constructor;
 
-  Constructor get lateInitializationLocalAlreadyInitializedConstructor {
-    return _lateInitializationLocalAlreadyInitializedConstructor ??=
-        index.getMember('dart:_internal', 'LateError', 'localAI');
-  }
+  late final Constructor lateInitializationLocalAlreadyInitializedConstructor =
+      index.getMember('dart:_internal', 'LateError', 'localAI') as Constructor;
 
-  Constructor get reachabilityErrorConstructor {
-    return _reachabilityErrorConstructor ??=
-        index.getMember('dart:_internal', 'ReachabilityError', '');
-  }
+  late final Constructor reachabilityErrorConstructor =
+      index.getMember('dart:_internal', 'ReachabilityError', '') as Constructor;
 
   InterfaceType bottomInterfaceType(Class klass, Nullability nullability) {
-    InterfaceType result = _bottomInterfaceTypes[klass];
+    InterfaceType? result = _bottomInterfaceTypes[klass];
     if (result == null) {
       return _bottomInterfaceTypes[klass] = new InterfaceType(
           klass,
diff --git a/pkg/kernel/lib/import_table.dart b/pkg/kernel/lib/import_table.dart
index c7662b4..1cc27c2 100644
--- a/pkg/kernel/lib/import_table.dart
+++ b/pkg/kernel/lib/import_table.dart
@@ -2,10 +2,9 @@
 // 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.9
-
 library kernel.import_table;
 
+// ignore: import_of_legacy_library_into_null_safe
 import 'ast.dart';
 
 abstract class ImportTable {
@@ -43,7 +42,7 @@
   List<Library> get importedLibraries => _importedLibraries;
 
   int addImport(Library target, String importPath) {
-    int index = _libraryIndex[target];
+    int? index = _libraryIndex[target];
     if (index != null) return index;
     index = _importPaths.length;
     _importPaths.add(importPath);
@@ -76,11 +75,12 @@
     table.addImport(referenceLibrary, '');
   }
 
-  void addLibraryImport(Library target) {
+  void addLibraryImport(Library? target) {
     if (target == referenceLibrary) return; // Self-reference is special.
     if (target == null) return;
     Uri referenceUri = referenceLibrary.importUri;
-    Uri targetUri = target.importUri;
+    Uri? targetUri = target.importUri;
+    // ignore: unnecessary_null_comparison
     if (targetUri == null) {
       throw '$referenceUri cannot refer to library without an import URI';
     }
@@ -111,7 +111,7 @@
   visitLibrary(Library node) {
     super.visitLibrary(node);
     for (Reference exportedReference in node.additionalExports) {
-      addLibraryImport(exportedReference.node.parent);
+      addLibraryImport(exportedReference.node.parent as Library);
     }
   }
 
diff --git a/pkg/kernel/lib/library_index.dart b/pkg/kernel/lib/library_index.dart
index f45aaa5..630763d 100644
--- a/pkg/kernel/lib/library_index.dart
+++ b/pkg/kernel/lib/library_index.dart
@@ -2,10 +2,9 @@
 // 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.9
-
 library kernel.library_index;
 
+// ignore: import_of_legacy_library_into_null_safe
 import 'ast.dart';
 
 /// Provides name-based access to library, class, and member AST nodes.
@@ -58,7 +57,7 @@
   }
 
   _ClassTable _getLibraryIndex(String uri) {
-    _ClassTable libraryIndex = _libraries[uri];
+    _ClassTable? libraryIndex = _libraries[uri];
     if (libraryIndex == null) {
       throw "The library '$uri' has not been indexed";
     }
@@ -71,7 +70,7 @@
   Library getLibrary(String uri) => _getLibraryIndex(uri).library;
 
   /// Like [getLibrary] but returns `null` if not found.
-  Library tryGetLibrary(String uri) => _libraries[uri]?.library;
+  Library? tryGetLibrary(String uri) => _libraries[uri]?.library;
 
   /// True if the library with the given URI exists and was indexed.
   bool containsLibrary(String uri) => _libraries.containsKey(uri);
@@ -84,7 +83,7 @@
   }
 
   /// Like [getClass] but returns `null` if not found.
-  Class tryGetClass(String library, String className) {
+  Class? tryGetClass(String library, String className) {
     return _libraries[library]?.tryGetClass(className);
   }
 
@@ -106,7 +105,7 @@
   }
 
   /// Like [getMember] but returns `null` if not found.
-  Member tryGetMember(String library, String className, String memberName) {
+  Member? tryGetMember(String library, String className, String memberName) {
     return _libraries[library]?.tryGetMember(className, memberName);
   }
 
@@ -125,7 +124,7 @@
   }
 
   /// Like [getTopLevelMember] but returns `null` if not found.
-  Member tryGetTopLevelMember(
+  Member? tryGetTopLevelMember(
       String library, String className, String memberName) {
     return tryGetMember(library, topLevel, memberName);
   }
@@ -134,31 +133,31 @@
 class _ClassTable {
   final Library library;
 
-  Map<String, _MemberTable> _classes;
+  Map<String, _MemberTable>? _classes;
 
   _ClassTable(this.library);
 
   Map<String, _MemberTable> get classes {
     if (_classes == null) {
       _classes = <String, _MemberTable>{};
-      _classes[LibraryIndex.topLevel] = new _MemberTable.topLevel(this);
+      _classes![LibraryIndex.topLevel] = new _MemberTable.topLevel(this);
       for (Class class_ in library.classes) {
-        _classes[class_.name] = new _MemberTable.fromClass(this, class_);
+        _classes![class_.name] = new _MemberTable.fromClass(this, class_);
       }
       for (Extension extension_ in library.extensions) {
-        _classes[extension_.name] =
+        _classes![extension_.name] =
             new _MemberTable.fromExtension(this, extension_);
       }
       for (Reference reference in library.additionalExports) {
         NamedNode node = reference.node;
         if (node is Class) {
-          _classes[node.name] = new _MemberTable.fromClass(this, node);
+          _classes![node.name] = new _MemberTable.fromClass(this, node);
         } else if (node is Extension) {
-          _classes[node.name] = new _MemberTable.fromExtension(this, node);
+          _classes![node.name] = new _MemberTable.fromExtension(this, node);
         }
       }
     }
-    return _classes;
+    return _classes!;
   }
 
   String get containerName {
@@ -166,7 +165,7 @@
   }
 
   _MemberTable _getClassIndex(String name) {
-    _MemberTable indexer = classes[name];
+    _MemberTable? indexer = classes[name];
     if (indexer == null) {
       throw "Class '$name' not found in $containerName";
     }
@@ -174,10 +173,10 @@
   }
 
   Class getClass(String name) {
-    return _getClassIndex(name).class_;
+    return _getClassIndex(name).class_!;
   }
 
-  Class tryGetClass(String name) {
+  Class? tryGetClass(String name) {
     return classes[name]?.class_;
   }
 
@@ -185,16 +184,16 @@
     return _getClassIndex(className).getMember(memberName);
   }
 
-  Member tryGetMember(String className, String memberName) {
+  Member? tryGetMember(String className, String memberName) {
     return classes[className]?.tryGetMember(memberName);
   }
 }
 
 class _MemberTable {
   final _ClassTable parent;
-  final Class class_; // Null for top-level or extension.
-  final Extension extension_; // Null for top-level or class.
-  Map<String, Member> _members;
+  final Class? class_; // Null for top-level or extension.
+  final Extension? extension_; // Null for top-level or class.
+  Map<String, Member>? _members;
 
   Library get library => parent.library;
 
@@ -208,17 +207,17 @@
     if (_members == null) {
       _members = <String, Member>{};
       if (class_ != null) {
-        class_.procedures.forEach(addMember);
-        class_.fields.forEach(addMember);
-        class_.constructors.forEach(addMember);
+        class_!.procedures.forEach(_addMember);
+        class_!.fields.forEach(_addMember);
+        class_!.constructors.forEach(_addMember);
       } else if (extension_ != null) {
-        extension_.members.forEach(addExtensionMember);
+        extension_!.members.forEach(_addExtensionMember);
       } else {
-        library.procedures.forEach(addMember);
-        library.fields.forEach(addMember);
+        library.procedures.forEach(_addMember);
+        library.fields.forEach(_addMember);
       }
     }
-    return _members;
+    return _members!;
   }
 
   String getDisambiguatedName(Member member) {
@@ -229,13 +228,13 @@
     return member.name.text;
   }
 
-  void addMember(Member member) {
+  void _addMember(Member member) {
     if (member.name.isPrivate && member.name.library != library) {
       // Members whose name is private to other libraries cannot currently
       // be found with the LibraryIndex class.
       return;
     }
-    _members[getDisambiguatedName(member)] = member;
+    _members![getDisambiguatedName(member)] = member;
   }
 
   String getDisambiguatedExtensionName(
@@ -252,7 +251,7 @@
     return extensionMember.name.text;
   }
 
-  void addExtensionMember(ExtensionMemberDescriptor extensionMember) {
+  void _addExtensionMember(ExtensionMemberDescriptor extensionMember) {
     final NamedNode replacement = extensionMember.member.node;
     if (replacement is! Member) return;
     Member member = replacement;
@@ -263,21 +262,21 @@
     }
 
     final String name = getDisambiguatedExtensionName(extensionMember);
-    _members[name] = replacement;
+    _members![name] = replacement;
   }
 
   String get containerName {
     if (class_ != null) {
-      return "class '${class_.name}' in ${parent.containerName}";
+      return "class '${class_!.name}' in ${parent.containerName}";
     } else if (extension_ != null) {
-      return "extension '${extension_.name}' in ${parent.containerName}";
+      return "extension '${extension_!.name}' in ${parent.containerName}";
     } else {
       return "top-level of ${parent.containerName}";
     }
   }
 
   Member getMember(String name) {
-    Member member = members[name];
+    Member? member = members[name];
     if (member == null) {
       String message = "A member with disambiguated name '$name' was not found "
           "in $containerName";
@@ -291,5 +290,5 @@
     return member;
   }
 
-  Member tryGetMember(String name) => members[name];
+  Member? tryGetMember(String name) => members[name];
 }
diff --git a/pkg/kernel/lib/src/assumptions.dart b/pkg/kernel/lib/src/assumptions.dart
index e8c759b..00b07a9 100644
--- a/pkg/kernel/lib/src/assumptions.dart
+++ b/pkg/kernel/lib/src/assumptions.dart
@@ -2,8 +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.
 
-// @dart = 2.9
-
+// ignore: import_of_legacy_library_into_null_safe
 import '../ast.dart';
 
 /// Pairs of [TypeParameter]s that are currently assumed to be
@@ -25,7 +24,7 @@
   }
 
   void _removeAssumption(TypeParameter a, TypeParameter b) {
-    TypeParameter assumption = _assumptionMap.remove(a);
+    TypeParameter? assumption = _assumptionMap.remove(a);
     assert(identical(assumption, b));
   }
 
diff --git a/pkg/kernel/lib/src/non_null.dart b/pkg/kernel/lib/src/non_null.dart
index 8254073..c3df22a 100644
--- a/pkg/kernel/lib/src/non_null.dart
+++ b/pkg/kernel/lib/src/non_null.dart
@@ -2,8 +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.md file.
 
-// @dart = 2.9
-
+// ignore: import_of_legacy_library_into_null_safe
 import '../ast.dart';
 
 /// Returns the type defines as `NonNull(type)` in the nnbd specification.
@@ -15,23 +14,23 @@
 /// specification.
 ///
 /// The visitor returns `null` if `NonNull(T) = T`.
-class _NonNullVisitor implements DartTypeVisitor<DartType> {
+class _NonNullVisitor implements DartTypeVisitor<DartType?> {
   const _NonNullVisitor();
 
   @override
-  DartType defaultDartType(DartType node) {
+  DartType? defaultDartType(DartType node) {
     throw new UnsupportedError(
         "Unexpected DartType ${node} (${node.runtimeType})");
   }
 
   @override
-  DartType visitBottomType(BottomType node) => null;
+  DartType? visitBottomType(BottomType node) => null;
 
   @override
-  DartType visitDynamicType(DynamicType node) => null;
+  DartType? visitDynamicType(DynamicType node) => null;
 
   @override
-  DartType visitFunctionType(FunctionType node) {
+  DartType? visitFunctionType(FunctionType node) {
     if (node.declaredNullability == Nullability.nonNullable) {
       return null;
     }
@@ -39,8 +38,8 @@
   }
 
   @override
-  DartType visitFutureOrType(FutureOrType node) {
-    DartType typeArgument = node.typeArgument.accept(this);
+  DartType? visitFutureOrType(FutureOrType node) {
+    DartType? typeArgument = node.typeArgument.accept(this);
     if (node.declaredNullability == Nullability.nonNullable &&
         typeArgument == null) {
       return null;
@@ -50,7 +49,7 @@
   }
 
   @override
-  DartType visitInterfaceType(InterfaceType node) {
+  DartType? visitInterfaceType(InterfaceType node) {
     if (node.declaredNullability == Nullability.nonNullable) {
       return null;
     }
@@ -58,10 +57,10 @@
   }
 
   @override
-  DartType visitInvalidType(InvalidType node) => null;
+  DartType? visitInvalidType(InvalidType node) => null;
 
   @override
-  DartType visitNeverType(NeverType node) {
+  DartType? visitNeverType(NeverType node) {
     if (node.declaredNullability == Nullability.nonNullable) {
       return null;
     }
@@ -69,12 +68,12 @@
   }
 
   @override
-  DartType visitNullType(NullType node) {
+  DartType? visitNullType(NullType node) {
     return const NeverType.nonNullable();
   }
 
   @override
-  DartType visitTypeParameterType(TypeParameterType node) {
+  DartType? visitTypeParameterType(TypeParameterType node) {
     if (node.nullability == Nullability.nonNullable) {
       return null;
     }
@@ -84,7 +83,7 @@
         // nullability to non-nullable.
         return node.withDeclaredNullability(Nullability.nonNullable);
       }
-      DartType promotedBound = node.promotedBound.accept(this);
+      DartType? promotedBound = node.promotedBound.accept(this);
       if (promotedBound == null) {
         // The promoted bound could not be made non-nullable so we set the
         // declared nullability to undetermined.
@@ -110,7 +109,7 @@
         // to non-nullable.
         return node.withDeclaredNullability(Nullability.nonNullable);
       }
-      DartType bound = node.bound.accept(this);
+      DartType? bound = node.bound.accept(this);
       if (bound == null) {
         // The bound could not be made non-nullable so we set the declared
         // nullability to undetermined.
@@ -130,7 +129,7 @@
   }
 
   @override
-  DartType visitTypedefType(TypedefType node) {
+  DartType? visitTypedefType(TypedefType node) {
     if (node.declaredNullability == Nullability.nonNullable) {
       return null;
     }
@@ -138,5 +137,5 @@
   }
 
   @override
-  DartType visitVoidType(VoidType node) => null;
+  DartType? visitVoidType(VoidType node) => null;
 }
diff --git a/pkg/kernel/lib/src/printer.dart b/pkg/kernel/lib/src/printer.dart
index c6a8f57..d14c8cd 100644
--- a/pkg/kernel/lib/src/printer.dart
+++ b/pkg/kernel/lib/src/printer.dart
@@ -2,8 +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.
 
-// @dart = 2.9
-
+// ignore: import_of_legacy_library_into_null_safe
 import '../ast.dart';
 import 'text_util.dart';
 
@@ -45,20 +44,20 @@
 
   /// If non-null, a maximum of [maxStatementDepth] nested statements are
   /// printed. If exceeded, '...' is printed instead.
-  final int maxStatementDepth;
+  final int? maxStatementDepth;
 
   /// If non-null, a maximum of [maxStatementsLength] statements are printed
   /// within the same block.
-  final int maxStatementsLength;
+  final int? maxStatementsLength;
 
   /// If non-null, a maximum of [maxExpressionDepth] nested expression are
   /// printed. If exceeded, '...' is printed instead.
-  final int maxExpressionDepth;
+  final int? maxExpressionDepth;
 
   /// If non-null, a maximum of [maxExpressionsLength] expression are printed
   /// within the same list of expressions, for instance in list/set literals.
   /// If exceeded, '...' is printed instead.
-  final int maxExpressionsLength;
+  final int? maxExpressionsLength;
 
   const AstTextStrategy(
       {this.includeLibraryNamesInTypes: false,
@@ -78,8 +77,8 @@
   int _statementLevel = 0;
   int _expressionLevel = 0;
   int _indentationLevel = 0;
-  Map<LabeledStatement, String> _labelNames;
-  Map<VariableDeclaration, String> _variableNames;
+  late final Map<LabeledStatement, String> _labelNames = {};
+  late final Map<VariableDeclaration, String> _variableNames = {};
 
   AstPrinter(this._strategy);
 
@@ -97,29 +96,29 @@
     _sb.write(value);
   }
 
-  void writeClassName(Reference reference, {bool forType: false}) {
+  void writeClassName(Reference? reference, {bool forType: false}) {
     _sb.write(qualifiedClassNameToStringByReference(reference,
         includeLibraryName: forType
             ? _strategy.includeLibraryNamesInTypes
             : _strategy.includeLibraryNamesInMembers));
   }
 
-  void writeTypedefName(Reference reference) {
+  void writeTypedefName(Reference? reference) {
     _sb.write(qualifiedTypedefNameToStringByReference(reference,
         includeLibraryName: _strategy.includeLibraryNamesInTypes));
   }
 
-  void writeExtensionName(Reference reference) {
+  void writeExtensionName(Reference? reference) {
     _sb.write(qualifiedExtensionNameToStringByReference(reference,
         includeLibraryName: _strategy.includeLibraryNamesInMembers));
   }
 
-  void writeMemberName(Reference reference) {
+  void writeMemberName(Reference? reference) {
     _sb.write(qualifiedMemberNameToStringByReference(reference,
         includeLibraryName: _strategy.includeLibraryNamesInMembers));
   }
 
-  void writeInterfaceMemberName(Reference reference, Name name) {
+  void writeInterfaceMemberName(Reference? reference, Name? name) {
     if (name != null && (reference == null || reference.node == null)) {
       writeName(name);
     } else {
@@ -130,7 +129,7 @@
     }
   }
 
-  void writeName(Name name) {
+  void writeName(Name? name) {
     _sb.write(nameToString(name,
         includeLibraryName: _strategy.includeLibraryNamesInMembers));
   }
@@ -154,7 +153,6 @@
   }
 
   String getLabelName(LabeledStatement node) {
-    _labelNames ??= {};
     return _labelNames[node] ??= 'label${_labelNames.length}';
   }
 
@@ -162,7 +160,6 @@
     if (node.name != null) {
       return node.name;
     }
-    _variableNames ??= {};
     return _variableNames[node] ??= '#${_variableNames.length}';
   }
 
@@ -178,7 +175,7 @@
     int oldStatementLevel = _statementLevel;
     _statementLevel++;
     if (_strategy.maxStatementDepth != null &&
-        _statementLevel > _strategy.maxStatementDepth) {
+        _statementLevel > _strategy.maxStatementDepth!) {
       _sb.write('...');
     } else {
       node.toTextInternal(this);
@@ -186,11 +183,11 @@
     _statementLevel = oldStatementLevel;
   }
 
-  void writeExpression(Expression node, {int minimumPrecedence}) {
+  void writeExpression(Expression node, {int? minimumPrecedence}) {
     int oldExpressionLevel = _expressionLevel;
     _expressionLevel++;
     if (_strategy.maxExpressionDepth != null &&
-        _expressionLevel > _strategy.maxExpressionDepth) {
+        _expressionLevel > _strategy.maxExpressionDepth!) {
       _sb.write('...');
     } else {
       bool needsParentheses =
@@ -268,7 +265,7 @@
           if (type is InterfaceType &&
               type.className.node != null &&
               type.classNode.name == 'Object') {
-            Uri uri = type.classNode.enclosingLibrary?.importUri;
+            Uri? uri = type.classNode.enclosingLibrary?.importUri;
             return uri?.scheme == 'dart' &&
                 uri?.path == 'core' &&
                 (type.nullability == Nullability.legacy ||
@@ -292,12 +289,12 @@
   void writeExpressions(List<Expression> expressions) {
     if (expressions.isNotEmpty &&
         _strategy.maxExpressionDepth != null &&
-        _expressionLevel + 1 > _strategy.maxExpressionDepth) {
+        _expressionLevel + 1 > _strategy.maxExpressionDepth!) {
       // The maximum expression depth will be exceeded for all [expressions].
       // Print the list as one occurrence '...' instead one per expression.
       _sb.write('...');
     } else if (_strategy.maxExpressionsLength != null &&
-        expressions.length > _strategy.maxExpressionsLength) {
+        expressions.length > _strategy.maxExpressionsLength!) {
       _sb.write('...');
     } else {
       for (int index = 0; index < expressions.length; index++) {
@@ -333,12 +330,12 @@
   void writeStatements(List<Statement> statements) {
     if (statements.isNotEmpty &&
         _strategy.maxStatementDepth != null &&
-        _statementLevel + 1 > _strategy.maxStatementDepth) {
+        _statementLevel + 1 > _strategy.maxStatementDepth!) {
       // The maximum statement depth will be exceeded for all [statements].
       // Print the list as one occurrence '...' instead one per statement.
       _sb.write(' ...');
     } else if (_strategy.maxStatementsLength != null &&
-        statements.length > _strategy.maxStatementsLength) {
+        statements.length > _strategy.maxStatementsLength!) {
       _sb.write(' ...');
     } else {
       for (Statement statement in statements) {
@@ -366,8 +363,8 @@
   /// the corresponding properties on [node].
   void writeVariableDeclaration(VariableDeclaration node,
       {bool includeModifiersAndType: true,
-      bool isLate,
-      DartType type,
+      bool? isLate,
+      DartType? type,
       bool includeInitializer: true}) {
     if (includeModifiersAndType) {
       if (node.isRequired) {
@@ -435,7 +432,8 @@
       _sb.write('}');
     }
     _sb.write(')');
-    Statement body = node.body;
+    Statement? body = node.body;
+    // ignore: unnecessary_null_comparison
     if (body != null) {
       if (body is ReturnStatement) {
         _sb.write(' => ');
diff --git a/pkg/kernel/lib/src/replacement_visitor.dart b/pkg/kernel/lib/src/replacement_visitor.dart
index 6e9a020..1d5a8db 100644
--- a/pkg/kernel/lib/src/replacement_visitor.dart
+++ b/pkg/kernel/lib/src/replacement_visitor.dart
@@ -2,32 +2,32 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE.md file.
 
-// @dart = 2.9
-
+// ignore: import_of_legacy_library_into_null_safe
 import '../ast.dart' hide MapEntry;
+// ignore: import_of_legacy_library_into_null_safe
 import '../type_algebra.dart';
 
 /// Helper visitor that clones a type if a nested type is replaced, and
 /// otherwise returns `null`.
-class ReplacementVisitor implements DartTypeVisitor1<DartType, int> {
+class ReplacementVisitor implements DartTypeVisitor1<DartType?, int> {
   const ReplacementVisitor();
 
-  Nullability visitNullability(DartType node) => null;
+  Nullability? visitNullability(DartType node) => null;
 
   @override
-  DartType visitFunctionType(FunctionType node, int variance) {
-    Nullability newNullability = visitNullability(node);
+  DartType? visitFunctionType(FunctionType node, int variance) {
+    Nullability? newNullability = visitNullability(node);
 
-    List<TypeParameter> newTypeParameters;
+    List<TypeParameter>? newTypeParameters;
     for (int i = 0; i < node.typeParameters.length; i++) {
       TypeParameter typeParameter = node.typeParameters[i];
       // TODO(johnniwinther): Bounds should not be null, even in case of
       // cyclic typedefs. Currently
       //   instantiate_to_bound/non_simple_class_parametrized_typedef_cycle
       // fails with this.
-      DartType newBound = typeParameter.bound
+      DartType? newBound = typeParameter.bound
           ?.accept1(this, Variance.combine(variance, Variance.invariant));
-      DartType newDefaultType = typeParameter.defaultType
+      DartType? newDefaultType = typeParameter.defaultType
           ?.accept1(this, Variance.combine(variance, Variance.invariant));
       if (newBound != null || newDefaultType != null) {
         newTypeParameters ??= node.typeParameters.toList(growable: false);
@@ -38,14 +38,14 @@
       }
     }
 
-    Substitution substitution;
+    Substitution? substitution;
     if (newTypeParameters != null) {
       List<TypeParameterType> typeParameterTypes =
-          new List<TypeParameterType>.filled(newTypeParameters.length, null);
-      for (int i = 0; i < newTypeParameters.length; i++) {
-        typeParameterTypes[i] = new TypeParameterType.forAlphaRenaming(
-            node.typeParameters[i], newTypeParameters[i]);
-      }
+          new List<TypeParameterType>.generate(newTypeParameters.length,
+              (int i) {
+        return new TypeParameterType.forAlphaRenaming(
+            node.typeParameters[i], newTypeParameters![i]);
+      }, growable: false);
       substitution =
           Substitution.fromPairs(node.typeParameters, typeParameterTypes);
       for (int i = 0; i < newTypeParameters.length; i++) {
@@ -54,19 +54,19 @@
       }
     }
 
-    DartType visitType(DartType type, int variance) {
+    DartType? visitType(DartType? type, int variance) {
       if (type == null) return null;
-      DartType result = type.accept1(this, variance);
+      DartType? result = type.accept1(this, variance);
       if (substitution != null) {
         result = substitution.substituteType(result ?? type);
       }
       return result;
     }
 
-    DartType newReturnType = visitType(node.returnType, variance);
-    List<DartType> newPositionalParameters = null;
+    DartType? newReturnType = visitType(node.returnType, variance);
+    List<DartType>? newPositionalParameters = null;
     for (int i = 0; i < node.positionalParameters.length; i++) {
-      DartType newType = visitType(node.positionalParameters[i],
+      DartType? newType = visitType(node.positionalParameters[i],
           Variance.combine(variance, Variance.contravariant));
       if (newType != null) {
         newPositionalParameters ??=
@@ -74,18 +74,19 @@
         newPositionalParameters[i] = newType;
       }
     }
-    List<NamedType> newNamedParameters = null;
+    List<NamedType>? newNamedParameters = null;
     for (int i = 0; i < node.namedParameters.length; i++) {
-      DartType newType = visitType(node.namedParameters[i].type,
+      DartType? newType = visitType(node.namedParameters[i].type,
           Variance.combine(variance, Variance.contravariant));
-      NamedType newNamedType =
+      NamedType? newNamedType =
           createNamedType(node.namedParameters[i], newType);
       if (newNamedType != null) {
         newNamedParameters ??= node.namedParameters.toList(growable: false);
         newNamedParameters[i] = newNamedType;
       }
     }
-    DartType newTypedefType = visitType(node.typedefType, variance);
+    TypedefType? newTypedefType =
+        visitType(node.typedefType, variance) as TypedefType?;
 
     return createFunctionType(
         node,
@@ -97,7 +98,7 @@
         newTypedefType);
   }
 
-  NamedType createNamedType(NamedType node, DartType newType) {
+  NamedType? createNamedType(NamedType node, DartType? newType) {
     if (newType == null) {
       return null;
     } else {
@@ -105,14 +106,14 @@
     }
   }
 
-  DartType createFunctionType(
+  DartType? createFunctionType(
       FunctionType node,
-      Nullability newNullability,
-      List<TypeParameter> newTypeParameters,
-      DartType newReturnType,
-      List<DartType> newPositionalParameters,
-      List<NamedType> newNamedParameters,
-      TypedefType newTypedefType) {
+      Nullability? newNullability,
+      List<TypeParameter>? newTypeParameters,
+      DartType? newReturnType,
+      List<DartType>? newPositionalParameters,
+      List<NamedType>? newNamedParameters,
+      TypedefType? newTypedefType) {
     if (newNullability == null &&
         newReturnType == null &&
         newPositionalParameters == null &&
@@ -133,11 +134,11 @@
   }
 
   @override
-  DartType visitInterfaceType(InterfaceType node, int variance) {
-    Nullability newNullability = visitNullability(node);
-    List<DartType> newTypeArguments = null;
+  DartType? visitInterfaceType(InterfaceType node, int variance) {
+    Nullability? newNullability = visitNullability(node);
+    List<DartType>? newTypeArguments = null;
     for (int i = 0; i < node.typeArguments.length; i++) {
-      DartType substitution = node.typeArguments[i].accept1(this, variance);
+      DartType? substitution = node.typeArguments[i].accept1(this, variance);
       if (substitution != null) {
         newTypeArguments ??= node.typeArguments.toList(growable: false);
         newTypeArguments[i] = substitution;
@@ -146,8 +147,8 @@
     return createInterfaceType(node, newNullability, newTypeArguments);
   }
 
-  DartType createInterfaceType(InterfaceType node, Nullability newNullability,
-      List<DartType> newTypeArguments) {
+  DartType? createInterfaceType(InterfaceType node, Nullability? newNullability,
+      List<DartType>? newTypeArguments) {
     if (newNullability == null && newTypeArguments == null) {
       // No nullability or type arguments needed to be substituted.
       return null;
@@ -160,14 +161,14 @@
   }
 
   @override
-  DartType visitFutureOrType(FutureOrType node, int variance) {
-    Nullability newNullability = visitNullability(node);
-    DartType newTypeArgument = node.typeArgument.accept1(this, variance);
+  DartType? visitFutureOrType(FutureOrType node, int variance) {
+    Nullability? newNullability = visitNullability(node);
+    DartType? newTypeArgument = node.typeArgument.accept1(this, variance);
     return createFutureOrType(node, newNullability, newTypeArgument);
   }
 
-  DartType createFutureOrType(
-      FutureOrType node, Nullability newNullability, DartType newTypeArgument) {
+  DartType? createFutureOrType(FutureOrType node, Nullability? newNullability,
+      DartType? newTypeArgument) {
     if (newNullability == null && newTypeArgument == null) {
       // No nullability or type arguments needed to be substituted.
       return null;
@@ -178,15 +179,15 @@
   }
 
   @override
-  DartType visitDynamicType(DynamicType node, int variance) => null;
+  DartType? visitDynamicType(DynamicType node, int variance) => null;
 
   @override
-  DartType visitNeverType(NeverType node, int variance) {
-    Nullability newNullability = visitNullability(node);
+  DartType? visitNeverType(NeverType node, int variance) {
+    Nullability? newNullability = visitNullability(node);
     return createNeverType(node, newNullability);
   }
 
-  DartType createNeverType(NeverType node, Nullability newNullability) {
+  DartType? createNeverType(NeverType node, Nullability? newNullability) {
     if (newNullability == null) {
       // No nullability needed to be substituted.
       return null;
@@ -196,20 +197,20 @@
   }
 
   @override
-  DartType visitNullType(NullType node, int variance) => null;
+  DartType? visitNullType(NullType node, int variance) => null;
 
   @override
-  DartType visitInvalidType(InvalidType node, int variance) => null;
+  DartType? visitInvalidType(InvalidType node, int variance) => null;
 
   @override
-  DartType visitBottomType(BottomType node, int variance) => null;
+  DartType? visitBottomType(BottomType node, int variance) => null;
 
   @override
-  DartType visitVoidType(VoidType node, int variance) => null;
+  DartType? visitVoidType(VoidType node, int variance) => null;
 
   @override
-  DartType visitTypeParameterType(TypeParameterType node, int variance) {
-    Nullability newNullability = visitNullability(node);
+  DartType? visitTypeParameterType(TypeParameterType node, int variance) {
+    Nullability? newNullability = visitNullability(node);
     if (node.promotedBound != null) {
       DartType newPromotedBound = node.promotedBound.accept1(this, variance);
       return createPromotedTypeParameterType(
@@ -218,8 +219,8 @@
     return createTypeParameterType(node, newNullability);
   }
 
-  DartType createTypeParameterType(
-      TypeParameterType node, Nullability newNullability) {
+  DartType? createTypeParameterType(
+      TypeParameterType node, Nullability? newNullability) {
     if (newNullability == null) {
       // No nullability needed to be substituted.
       return null;
@@ -228,8 +229,8 @@
     }
   }
 
-  DartType createPromotedTypeParameterType(TypeParameterType node,
-      Nullability newNullability, DartType newPromotedBound) {
+  DartType? createPromotedTypeParameterType(TypeParameterType node,
+      Nullability? newNullability, DartType? newPromotedBound) {
     if (newNullability == null && newPromotedBound == null) {
       // No nullability or bound needed to be substituted.
       return null;
@@ -242,11 +243,11 @@
   }
 
   @override
-  DartType visitTypedefType(TypedefType node, int variance) {
-    Nullability newNullability = visitNullability(node);
-    List<DartType> newTypeArguments = null;
+  DartType? visitTypedefType(TypedefType node, int variance) {
+    Nullability? newNullability = visitNullability(node);
+    List<DartType>? newTypeArguments = null;
     for (int i = 0; i < node.typeArguments.length; i++) {
-      DartType substitution = node.typeArguments[i].accept1(
+      DartType? substitution = node.typeArguments[i].accept1(
           this,
           Variance.combine(
               variance, node.typedefNode.typeParameters[i].variance));
@@ -258,8 +259,8 @@
     return createTypedef(node, newNullability, newTypeArguments);
   }
 
-  DartType createTypedef(TypedefType node, Nullability newNullability,
-      List<DartType> newTypeArguments) {
+  DartType? createTypedef(TypedefType node, Nullability? newNullability,
+      List<DartType>? newTypeArguments) {
     if (newNullability == null && newTypeArguments == null) {
       // No nullability or type arguments needed to be substituted.
       return null;
@@ -272,5 +273,5 @@
   }
 
   @override
-  DartType defaultDartType(DartType node, int variance) => null;
+  DartType? defaultDartType(DartType node, int variance) => null;
 }
diff --git a/pkg/kernel/lib/src/text_util.dart b/pkg/kernel/lib/src/text_util.dart
index c7634ad..0e9e0cc 100644
--- a/pkg/kernel/lib/src/text_util.dart
+++ b/pkg/kernel/lib/src/text_util.dart
@@ -2,8 +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.
 
-// @dart = 2.9
-
+// ignore: import_of_legacy_library_into_null_safe
 import '../ast.dart';
 
 String nullabilityToString(Nullability nullability) {
@@ -17,10 +16,9 @@
     case Nullability.nonNullable:
       return '';
   }
-  throw "Unknown Nullability: $nullability";
 }
 
-String nameToString(Name node, {bool includeLibraryName: false}) {
+String nameToString(Name? node, {bool includeLibraryName: false}) {
   if (node == null) {
     return 'null';
   } else if (node.library != null && includeLibraryName) {
@@ -30,7 +28,7 @@
   }
 }
 
-String libraryNameToString(Library node) {
+String libraryNameToString(Library? node) {
   return node == null ? 'null' : node.name ?? 'library ${node.importUri}';
 }
 
@@ -65,17 +63,18 @@
   }
 }
 
-String qualifiedClassNameToStringByReference(Reference reference,
+String qualifiedClassNameToStringByReference(Reference? reference,
     {bool includeLibraryName: false}) {
   if (reference == null) {
     return '<missing-class-reference>';
   } else {
-    Class node = reference.node;
+    Class? node = reference.node as Class?;
     if (node != null) {
       return qualifiedClassNameToString(node,
           includeLibraryName: includeLibraryName);
     } else {
-      CanonicalName canonicalName = reference.canonicalName;
+      CanonicalName? canonicalName = reference.canonicalName;
+      // ignore: unnecessary_null_comparison
       if (canonicalName != null) {
         return qualifiedCanonicalNameToString(canonicalName,
             includeLibraryName: includeLibraryName);
@@ -86,7 +85,7 @@
   }
 }
 
-String classNameToString(Class node) {
+String classNameToString(Class? node) {
   return node == null
       ? 'null'
       : node.name ?? 'null-named class ${node.runtimeType} ${node.hashCode}';
@@ -103,17 +102,18 @@
   }
 }
 
-String qualifiedExtensionNameToStringByReference(Reference reference,
+String qualifiedExtensionNameToStringByReference(Reference? reference,
     {bool includeLibraryName: false}) {
   if (reference == null) {
     return '<missing-extension-reference>';
   } else {
-    Extension node = reference.node;
+    Extension? node = reference.node as Extension?;
     if (node != null) {
       return qualifiedExtensionNameToString(node,
           includeLibraryName: includeLibraryName);
     } else {
-      CanonicalName canonicalName = reference.canonicalName;
+      CanonicalName? canonicalName = reference.canonicalName;
+      // ignore: unnecessary_null_comparison
       if (canonicalName != null) {
         return qualifiedCanonicalNameToString(canonicalName,
             includeLibraryName: includeLibraryName);
@@ -124,7 +124,7 @@
   }
 }
 
-String extensionNameToString(Extension node) {
+String extensionNameToString(Extension? node) {
   return node == null
       ? 'null'
       : node.name ??
@@ -142,17 +142,18 @@
   }
 }
 
-String qualifiedTypedefNameToStringByReference(Reference reference,
+String qualifiedTypedefNameToStringByReference(Reference? reference,
     {bool includeLibraryName: false}) {
   if (reference == null) {
     return '<missing-typedef-reference>';
   } else {
-    Typedef node = reference.node;
+    Typedef? node = reference.node as Typedef?;
     if (node != null) {
       return qualifiedTypedefNameToString(node,
           includeLibraryName: includeLibraryName);
     } else {
-      CanonicalName canonicalName = reference.canonicalName;
+      CanonicalName? canonicalName = reference.canonicalName;
+      // ignore: unnecessary_null_comparison
       if (canonicalName != null) {
         return qualifiedCanonicalNameToString(canonicalName,
             includeLibraryName: includeLibraryName);
@@ -163,7 +164,7 @@
   }
 }
 
-String typedefNameToString(Typedef node) {
+String typedefNameToString(Typedef? node) {
   return node == null
       ? 'null'
       : node.name ?? 'null-named typedef ${node.runtimeType} ${node.hashCode}';
@@ -185,17 +186,18 @@
   }
 }
 
-String qualifiedMemberNameToStringByReference(Reference reference,
+String qualifiedMemberNameToStringByReference(Reference? reference,
     {bool includeLibraryName: false}) {
   if (reference == null) {
     return '<missing-member-reference>';
   } else {
-    Member node = reference.node;
+    Member? node = reference.node as Member?;
     if (node != null) {
       return qualifiedMemberNameToString(node,
           includeLibraryName: includeLibraryName);
     } else {
-      CanonicalName canonicalName = reference.canonicalName;
+      CanonicalName? canonicalName = reference.canonicalName;
+      // ignore: unnecessary_null_comparison
       if (canonicalName != null) {
         return qualifiedCanonicalNameToString(canonicalName,
             includeLibraryName: includeLibraryName);
@@ -238,7 +240,7 @@
       "null-named TypeParameter ${node.runtimeType} ${node.hashCode}";
 }
 
-String getEscapedCharacter(int codeUnit) {
+String? getEscapedCharacter(int codeUnit) {
   switch (codeUnit) {
     case 9:
       return r'\t';
@@ -266,9 +268,9 @@
 }
 
 String escapeString(String string) {
-  StringBuffer buffer;
+  StringBuffer? buffer;
   for (int i = 0; i < string.length; ++i) {
-    String character = getEscapedCharacter(string.codeUnitAt(i));
+    String? character = getEscapedCharacter(string.codeUnitAt(i));
     if (character != null) {
       buffer ??= new StringBuffer(string.substring(0, i));
       buffer.write(character);
diff --git a/pkg/kernel/lib/transformations/flags.dart b/pkg/kernel/lib/transformations/flags.dart
index cb6bafd..398afeb 100644
--- a/pkg/kernel/lib/transformations/flags.dart
+++ b/pkg/kernel/lib/transformations/flags.dart
@@ -2,10 +2,9 @@
 // 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.9
-
 library kernel.transformations.flags;
 
+// ignore: import_of_legacy_library_into_null_safe
 import '../ast.dart';
 
 /// Flags summarizing the kinds of AST nodes contained in a given member or
diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart
index 4ef6055..93a7b3a 100644
--- a/pkg/kernel/lib/visitor.dart
+++ b/pkg/kernel/lib/visitor.dart
@@ -2,13 +2,12 @@
 // 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.9
-
 library kernel.ast.visitor;
 
 import 'dart:core' hide MapEntry;
 import 'dart:collection';
 
+// ignore: import_of_legacy_library_into_null_safe
 import 'ast.dart';
 
 abstract class ExpressionVisitor<R> {
@@ -436,7 +435,7 @@
 /// value for each subnode. The visitor caches the computed values ensuring that
 /// each subnode is only visited once.
 abstract class ComputeOnceConstantVisitor<R> implements _ConstantCallback<R> {
-  _ConstantCallbackVisitor<R> _visitor;
+  late final _ConstantCallbackVisitor<R> _visitor;
   Map<Constant, R> cache = new LinkedHashMap.identity();
 
   ComputeOnceConstantVisitor() {
@@ -485,7 +484,7 @@
 /// The visitor records the visited node to ensure that each subnode is only
 /// visited once.
 abstract class VisitOnceConstantVisitor implements _ConstantCallback<void> {
-  _ConstantCallbackVisitor<void> _visitor;
+  late final _ConstantCallbackVisitor<void> _visitor;
   Set<Constant> cache = new LinkedHashSet.identity();
 
   VisitOnceConstantVisitor() {
@@ -673,21 +672,21 @@
 
 /// Visitor mixin that returns a value of type [R] or `null` and uses `null` as
 /// its base case.
-mixin VisitorNullMixin<R> implements Visitor<R /*?*/ > {
+mixin VisitorNullMixin<R> implements Visitor<R?> {
   @override
-  R defaultNode(Node node) => null;
+  R? defaultNode(Node node) => null;
 
   @override
-  R visitClassReference(Class node) => null;
+  R? visitClassReference(Class node) => null;
 
   @override
-  R visitTypedefReference(Typedef node) => null;
+  R? visitTypedefReference(Typedef node) => null;
 
   @override
-  R defaultConstantReference(Constant node) => null;
+  R? defaultConstantReference(Constant node) => null;
 
   @override
-  R defaultMemberReference(Member node) => null;
+  R? defaultMemberReference(Member node) => null;
 }
 
 /// Visitor mixin that returns void.
@@ -741,11 +740,10 @@
 
 /// Recursive visitor that returns a result of type [R] or `null` from its
 /// visit methods.
-class RecursiveResultVisitor<R> extends Visitor<R /*?*/ >
-    with VisitorNullMixin<R> {
+class RecursiveResultVisitor<R> extends Visitor<R?> with VisitorNullMixin<R> {
   const RecursiveResultVisitor();
 
-  R defaultNode(Node node) {
+  R? defaultNode(Node node) {
     node.visitChildren(this);
     return null;
   }
diff --git a/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart b/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart
index be0d1ab..83b7cc5 100644
--- a/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart
+++ b/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart
@@ -57,7 +57,7 @@
 
   static Pointer<Isolate> createLightweightIsolate(
       String name, Pointer<Void> peer) {
-    final cname = Utf8.toUtf8(name);
+    final cname = name.toNativeUtf8();
     IGH_MsanUnpoison(cname.cast(), name.length + 10);
     try {
       final isolate = IGH_CreateIsolate(cname, peer);
@@ -74,9 +74,9 @@
     final dartScriptUri = sdkRoot.resolve(
         'runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart');
     final dartScript = dartScriptUri.toString();
-    final libraryUri = Utf8.toUtf8(dartScript);
+    final libraryUri = dartScript.toNativeUtf8();
     IGH_MsanUnpoison(libraryUri.cast(), dartScript.length + 1);
-    final functionName = Utf8.toUtf8(name);
+    final functionName = name.toNativeUtf8();
     IGH_MsanUnpoison(functionName.cast(), name.length + 1);
 
     IGH_StartIsolate(
@@ -106,7 +106,7 @@
 }
 
 Future withPeerPointer(fun(Pointer<Void> peer)) async {
-  final Pointer<Void> peer = Utf8.toUtf8('abc').cast();
+  final Pointer<Void> peer = 'abc'.toNativeUtf8().cast();
   FfiBindings.IGH_MsanUnpoison(peer.cast(), 'abc'.length + 1);
   try {
     await fun(peer);
@@ -116,12 +116,12 @@
   } finally {
     // The shutdown callback is called before the exit listeners are notified, so
     // we can validate that a->x has been changed.
-    Expect.isTrue(Utf8.fromUtf8(peer.cast()).startsWith('xb'));
+    Expect.isTrue(peer.cast<Utf8>().toDartString().startsWith('xb'));
 
     // The cleanup callback is called after after notifying exit listeners. So we
     // wait a little here to ensure the write of the callback has arrived.
     await Future.delayed(const Duration(milliseconds: 100));
-    Expect.equals('xbz', Utf8.fromUtf8(peer.cast()));
+    Expect.equals('xbz', peer.cast<Utf8>().toDartString());
     calloc.free(peer);
   }
 }
diff --git a/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart b/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart
index 73366bb..4611883 100644
--- a/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart
+++ b/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart
@@ -57,7 +57,7 @@
 
   static Pointer<Isolate> createLightweightIsolate(
       String name, Pointer<Void> peer) {
-    final cname = Utf8.toUtf8(name);
+    final cname = name.toNativeUtf8();
     IGH_MsanUnpoison(cname.cast(), name.length + 10);
     try {
       final isolate = IGH_CreateIsolate(cname, peer);
@@ -74,9 +74,9 @@
     final dartScriptUri = sdkRoot.resolve(
         'runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart');
     final dartScript = dartScriptUri.toString();
-    final libraryUri = Utf8.toUtf8(dartScript);
+    final libraryUri = dartScript.toNativeUtf8();
     IGH_MsanUnpoison(libraryUri.cast(), dartScript.length + 1);
-    final functionName = Utf8.toUtf8(name);
+    final functionName = name.toNativeUtf8();
     IGH_MsanUnpoison(functionName.cast(), name.length + 1);
 
     IGH_StartIsolate(
@@ -106,7 +106,7 @@
 }
 
 Future withPeerPointer(fun(Pointer<Void> peer)) async {
-  final Pointer<Void> peer = Utf8.toUtf8('abc').cast();
+  final Pointer<Void> peer = 'abc'.toNativeUtf8().cast();
   FfiBindings.IGH_MsanUnpoison(peer.cast(), 'abc'.length + 1);
   try {
     await fun(peer);
@@ -116,12 +116,12 @@
   } finally {
     // The shutdown callback is called before the exit listeners are notified, so
     // we can validate that a->x has been changed.
-    Expect.isTrue(Utf8.fromUtf8(peer.cast()).startsWith('xb'));
+    Expect.isTrue(peer.cast<Utf8>().toDartString().startsWith('xb'));
 
     // The cleanup callback is called after after notifying exit listeners. So we
     // wait a little here to ensure the write of the callback has arrived.
     await Future.delayed(const Duration(milliseconds: 100));
-    Expect.equals('xbz', Utf8.fromUtf8(peer.cast()));
+    Expect.equals('xbz', peer.cast<Utf8>().toDartString());
     calloc.free(peer);
   }
 }
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index ec47b19..0dfec5c 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -1314,7 +1314,7 @@
 
   // Prevent background compiler from adding deferred classes or canonicalizing
   // new types while classes are being sorted and type hashes are modified.
-  BackgroundCompiler::Stop(I);
+  NoBackgroundCompilerScope no_bg_compiler(T);
   SafepointWriteRwLocker ml(T, T->isolate_group()->program_lock());
 
   ClassTable* table = IG->class_table();
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 805f9dc..b623a08 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -1962,9 +1962,9 @@
   }
 
   void ReadFill(Deserializer* d, bool is_canonical) {
-    for (intptr_t id = start_index_; id < stop_index_; id += 1) {
+    for (intptr_t id = start_index_; id < stop_index_; id++) {
       const intptr_t length = d->ReadUnsigned();
-      ObjectPoolPtr pool = static_cast<ObjectPoolPtr>(d->Ref(id + 0));
+      ObjectPoolPtr pool = static_cast<ObjectPoolPtr>(d->Ref(id));
       Deserializer::InitializeHeader(pool, kObjectPoolCid,
                                      ObjectPool::InstanceSize(length));
       pool->untag()->length_ = length;
@@ -2113,7 +2113,7 @@
   }
 
   void ReadFill(Deserializer* d, bool is_canonical) {
-    for (intptr_t id = start_index_; id < stop_index_; id += 1) {
+    for (intptr_t id = start_index_; id < stop_index_; id++) {
       const intptr_t length = d->ReadUnsigned();
       PcDescriptorsPtr desc = static_cast<PcDescriptorsPtr>(d->Ref(id));
       Deserializer::InitializeHeader(desc, kPcDescriptorsCid,
@@ -2126,6 +2126,161 @@
 };
 
 #if !defined(DART_PRECOMPILED_RUNTIME)
+class CodeSourceMapSerializationCluster : public SerializationCluster {
+ public:
+  CodeSourceMapSerializationCluster() : SerializationCluster("CodeSourceMap") {}
+  ~CodeSourceMapSerializationCluster() {}
+
+  void Trace(Serializer* s, ObjectPtr object) {
+    CodeSourceMapPtr map = CodeSourceMap::RawCast(object);
+    objects_.Add(map);
+  }
+
+  void WriteAlloc(Serializer* s) {
+    s->WriteCid(kCodeSourceMapCid);
+    const intptr_t count = objects_.length();
+    s->WriteUnsigned(count);
+    for (intptr_t i = 0; i < count; i++) {
+      CodeSourceMapPtr map = objects_[i];
+      s->AssignRef(map);
+      AutoTraceObject(map);
+      const intptr_t length = map->untag()->length_;
+      s->WriteUnsigned(length);
+      target_memory_size_ +=
+          compiler::target::PcDescriptors::InstanceSize(length);
+    }
+  }
+
+  void WriteFill(Serializer* s) {
+    const intptr_t count = objects_.length();
+    for (intptr_t i = 0; i < count; i++) {
+      CodeSourceMapPtr map = objects_[i];
+      AutoTraceObject(map);
+      const intptr_t length = map->untag()->length_;
+      s->WriteUnsigned(length);
+      uint8_t* cdata = reinterpret_cast<uint8_t*>(map->untag()->data());
+      s->WriteBytes(cdata, length);
+    }
+  }
+
+ private:
+  GrowableArray<CodeSourceMapPtr> objects_;
+};
+#endif  // !DART_PRECOMPILED_RUNTIME
+
+class CodeSourceMapDeserializationCluster : public DeserializationCluster {
+ public:
+  CodeSourceMapDeserializationCluster()
+      : DeserializationCluster("CodeSourceMap") {}
+  ~CodeSourceMapDeserializationCluster() {}
+
+  void ReadAlloc(Deserializer* d, bool is_canonical) {
+    start_index_ = d->next_index();
+    PageSpace* old_space = d->heap()->old_space();
+    const intptr_t count = d->ReadUnsigned();
+    for (intptr_t i = 0; i < count; i++) {
+      const intptr_t length = d->ReadUnsigned();
+      d->AssignRef(AllocateUninitialized(old_space,
+                                         CodeSourceMap::InstanceSize(length)));
+    }
+    stop_index_ = d->next_index();
+  }
+
+  void ReadFill(Deserializer* d, bool is_canonical) {
+    for (intptr_t id = start_index_; id < stop_index_; id++) {
+      const intptr_t length = d->ReadUnsigned();
+      CodeSourceMapPtr map = static_cast<CodeSourceMapPtr>(d->Ref(id));
+      Deserializer::InitializeHeader(map, kPcDescriptorsCid,
+                                     CodeSourceMap::InstanceSize(length));
+      map->untag()->length_ = length;
+      uint8_t* cdata = reinterpret_cast<uint8_t*>(map->untag()->data());
+      d->ReadBytes(cdata, length);
+    }
+  }
+};
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
+class CompressedStackMapsSerializationCluster : public SerializationCluster {
+ public:
+  CompressedStackMapsSerializationCluster()
+      : SerializationCluster("CompressedStackMaps") {}
+  ~CompressedStackMapsSerializationCluster() {}
+
+  void Trace(Serializer* s, ObjectPtr object) {
+    CompressedStackMapsPtr desc = CompressedStackMaps::RawCast(object);
+    objects_.Add(desc);
+  }
+
+  void WriteAlloc(Serializer* s) {
+    s->WriteCid(kCompressedStackMapsCid);
+    const intptr_t count = objects_.length();
+    s->WriteUnsigned(count);
+    for (intptr_t i = 0; i < count; i++) {
+      CompressedStackMapsPtr map = objects_[i];
+      s->AssignRef(map);
+      AutoTraceObject(map);
+      const intptr_t length = UntaggedCompressedStackMaps::SizeField::decode(
+          map->untag()->flags_and_size_);
+      s->WriteUnsigned(length);
+      target_memory_size_ +=
+          compiler::target::CompressedStackMaps::InstanceSize(length);
+    }
+  }
+
+  void WriteFill(Serializer* s) {
+    const intptr_t count = objects_.length();
+    for (intptr_t i = 0; i < count; i++) {
+      CompressedStackMapsPtr map = objects_[i];
+      AutoTraceObject(map);
+      s->WriteUnsigned(map->untag()->flags_and_size_);
+      const intptr_t length = UntaggedCompressedStackMaps::SizeField::decode(
+          map->untag()->flags_and_size_);
+      uint8_t* cdata = reinterpret_cast<uint8_t*>(map->untag()->data());
+      s->WriteBytes(cdata, length);
+    }
+  }
+
+ private:
+  GrowableArray<CompressedStackMapsPtr> objects_;
+};
+#endif  // !DART_PRECOMPILED_RUNTIME
+
+class CompressedStackMapsDeserializationCluster
+    : public DeserializationCluster {
+ public:
+  CompressedStackMapsDeserializationCluster()
+      : DeserializationCluster("CompressedStackMaps") {}
+  ~CompressedStackMapsDeserializationCluster() {}
+
+  void ReadAlloc(Deserializer* d, bool is_canonical) {
+    start_index_ = d->next_index();
+    PageSpace* old_space = d->heap()->old_space();
+    const intptr_t count = d->ReadUnsigned();
+    for (intptr_t i = 0; i < count; i++) {
+      const intptr_t length = d->ReadUnsigned();
+      d->AssignRef(AllocateUninitialized(
+          old_space, CompressedStackMaps::InstanceSize(length)));
+    }
+    stop_index_ = d->next_index();
+  }
+
+  void ReadFill(Deserializer* d, bool is_canonical) {
+    for (intptr_t id = start_index_; id < stop_index_; id++) {
+      const intptr_t flags_and_size = d->ReadUnsigned();
+      const intptr_t length =
+          UntaggedCompressedStackMaps::SizeField::decode(flags_and_size);
+      CompressedStackMapsPtr map =
+          static_cast<CompressedStackMapsPtr>(d->Ref(id));
+      Deserializer::InitializeHeader(map, kCompressedStackMapsCid,
+                                     CompressedStackMaps::InstanceSize(length));
+      map->untag()->flags_and_size_ = flags_and_size;
+      uint8_t* cdata = reinterpret_cast<uint8_t*>(map->untag()->data());
+      d->ReadBytes(cdata, length);
+    }
+  }
+};
+
+#if !defined(DART_PRECOMPILED_RUNTIME) && !defined(DART_COMPRESSED_POINTERS)
 // PcDescriptor, CompressedStackMaps, OneByteString, TwoByteString
 class RODataSerializationCluster : public SerializationCluster {
  public:
@@ -2186,8 +2341,9 @@
   GrowableArray<ObjectPtr> objects_;
   const char* const type_;
 };
-#endif  // !DART_PRECOMPILED_RUNTIME
+#endif  // !DART_PRECOMPILED_RUNTIME && !DART_COMPRESSED_POINTERS
 
+#if !defined(DART_COMPRESSED_POINTERS)
 class RODataDeserializationCluster : public DeserializationCluster {
  public:
   explicit RODataDeserializationCluster(intptr_t cid)
@@ -2228,6 +2384,7 @@
  private:
   const intptr_t cid_;
 };
+#endif  // !DART_COMPRESSED_POINTERS
 
 #if !defined(DART_PRECOMPILED_RUNTIME)
 class ExceptionHandlersSerializationCluster : public SerializationCluster {
@@ -5532,11 +5689,21 @@
     return new (Z) TypedDataSerializationCluster(cid);
   }
 
+#if !defined(DART_COMPRESSED_POINTERS)
+  // Sometimes we write memory images for read-only objects that contain no
+  // pointers. These can be mmapped directly, needing no relocation, and added
+  // to the list of heap pages. This gives us lazy/demand paging from the OS.
+  // We do not do this for snapshots without code to keep snapshots portable
+  // between machines with different word sizes. We do not do this when we use
+  // compressed pointers because we cannot always control the load address of
+  // the memory image, and it might be outside the 4GB region addressable by
+  // compressed pointers.
   if (Snapshot::IncludesCode(kind_)) {
     if (auto const type = ReadOnlyObjectType(cid)) {
       return new (Z) RODataSerializationCluster(Z, type, cid);
     }
   }
+#endif
 
   switch (cid) {
     case kClassCid:
@@ -5567,6 +5734,10 @@
       return new (Z) ObjectPoolSerializationCluster();
     case kPcDescriptorsCid:
       return new (Z) PcDescriptorsSerializationCluster();
+    case kCodeSourceMapCid:
+      return new (Z) CodeSourceMapSerializationCluster();
+    case kCompressedStackMapsCid:
+      return new (Z) CompressedStackMapsSerializationCluster();
     case kExceptionHandlersCid:
       return new (Z) ExceptionHandlersSerializationCluster();
     case kContextCid:
@@ -6224,6 +6395,7 @@
     return new (Z) TypedDataDeserializationCluster(cid);
   }
 
+#if !defined(DART_COMPRESSED_POINTERS)
   if (Snapshot::IncludesCode(kind_)) {
     switch (cid) {
       case kPcDescriptorsCid:
@@ -6238,6 +6410,7 @@
         break;
     }
   }
+#endif
 
   switch (cid) {
     case kClassCid:
@@ -6270,6 +6443,10 @@
       return new (Z) ObjectPoolDeserializationCluster();
     case kPcDescriptorsCid:
       return new (Z) PcDescriptorsDeserializationCluster();
+    case kCodeSourceMapCid:
+      return new (Z) CodeSourceMapDeserializationCluster();
+    case kCompressedStackMapsCid:
+      return new (Z) CompressedStackMapsDeserializationCluster();
     case kExceptionHandlersCid:
       return new (Z) ExceptionHandlersDeserializationCluster();
     case kContextCid:
diff --git a/runtime/vm/compiler/assembler/assembler_arm.cc b/runtime/vm/compiler/assembler/assembler_arm.cc
index 4ba28d6..8bad1fc 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm.cc
@@ -1593,6 +1593,10 @@
   ldr(rd, Address(THR, target::Thread::isolate_offset()));
 }
 
+void Assembler::LoadIsolateGroup(Register rd) {
+  ldr(rd, Address(THR, target::Thread::isolate_group_offset()));
+}
+
 bool Assembler::CanLoadFromObjectPool(const Object& object) const {
   ASSERT(IsOriginalObject(object));
   if (!constant_pool_allowed()) {
@@ -3388,12 +3392,12 @@
   ASSERT(cid > 0);
 
   const intptr_t shared_table_offset =
-      target::Isolate::shared_class_table_offset();
+      target::IsolateGroup::shared_class_table_offset();
   const intptr_t table_offset =
       target::SharedClassTable::class_heap_stats_table_offset();
   const intptr_t class_offset = target::ClassTable::ClassOffsetFor(cid);
 
-  LoadIsolate(dest);
+  LoadIsolateGroup(dest);
   ldr(dest, Address(dest, shared_table_offset));
   ldr(dest, Address(dest, table_offset));
   AddImmediate(dest, class_offset);
diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h
index 62a6414..4efc1e9 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.h
+++ b/runtime/vm/compiler/assembler/assembler_arm.h
@@ -826,6 +826,7 @@
   void SetupGlobalPoolAndDispatchTable();
 
   void LoadIsolate(Register rd);
+  void LoadIsolateGroup(Register dst);
 
   // Load word from pool from the given index using encoding that
   // InstructionPattern::DecodeLoadWordFromPool can decode.
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.cc b/runtime/vm/compiler/assembler/assembler_arm64.cc
index 29a0ec9..f1d8195 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm64.cc
@@ -466,6 +466,10 @@
   ldr(dst, Address(THR, target::Thread::isolate_offset()));
 }
 
+void Assembler::LoadIsolateGroup(Register rd) {
+  ldr(rd, Address(THR, target::Thread::isolate_group_offset()));
+}
+
 void Assembler::LoadObjectHelper(Register dst,
                                  const Object& object,
                                  bool is_unique) {
@@ -1717,12 +1721,12 @@
   ASSERT(cid > 0);
 
   const intptr_t shared_table_offset =
-      target::Isolate::shared_class_table_offset();
+      target::IsolateGroup::shared_class_table_offset();
   const intptr_t table_offset =
       target::SharedClassTable::class_heap_stats_table_offset();
   const intptr_t class_offset = target::ClassTable::ClassOffsetFor(cid);
 
-  LoadIsolate(temp_reg);
+  LoadIsolateGroup(temp_reg);
   ldr(temp_reg, Address(temp_reg, shared_table_offset));
   ldr(temp_reg, Address(temp_reg, table_offset));
   AddImmediate(temp_reg, class_offset);
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.h b/runtime/vm/compiler/assembler/assembler_arm64.h
index dec46f3..1d6a830 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.h
+++ b/runtime/vm/compiler/assembler/assembler_arm64.h
@@ -1704,6 +1704,7 @@
                        const ExternalLabel* label,
                        ObjectPoolBuilderEntry::Patchability patchable);
   void LoadIsolate(Register dst);
+  void LoadIsolateGroup(Register dst);
 
   // Note: the function never clobbers TMP, TMP2 scratch registers.
   void LoadObject(Register dst, const Object& obj);
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.cc b/runtime/vm/compiler/assembler/assembler_ia32.cc
index 99a7a02..7c5abdd 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.cc
+++ b/runtime/vm/compiler/assembler/assembler_ia32.cc
@@ -1854,6 +1854,10 @@
   movl(dst, Address(THR, target::Thread::isolate_offset()));
 }
 
+void Assembler::LoadIsolateGroup(Register dst) {
+  movl(dst, Address(THR, target::Thread::isolate_group_offset()));
+}
+
 void Assembler::LoadObject(Register dst,
                            const Object& object,
                            bool movable_referent) {
@@ -2469,13 +2473,13 @@
   Address state_address(kNoRegister, 0);
 
   const intptr_t shared_table_offset =
-      target::Isolate::shared_class_table_offset();
+      target::IsolateGroup::shared_class_table_offset();
   const intptr_t table_offset =
       target::SharedClassTable::class_heap_stats_table_offset();
   const intptr_t class_offset = target::ClassTable::ClassOffsetFor(cid);
 
   ASSERT(temp_reg != kNoRegister);
-  LoadIsolate(temp_reg);
+  LoadIsolateGroup(temp_reg);
   movl(temp_reg, Address(temp_reg, shared_table_offset));
   movl(temp_reg, Address(temp_reg, table_offset));
   cmpb(Address(temp_reg, class_offset), Immediate(0));
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.h b/runtime/vm/compiler/assembler/assembler_ia32.h
index dfa7f35..82b9745 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.h
+++ b/runtime/vm/compiler/assembler/assembler_ia32.h
@@ -657,6 +657,7 @@
   void Drop(intptr_t stack_elements);
 
   void LoadIsolate(Register dst);
+  void LoadIsolateGroup(Register dst);
 
   void LoadUniqueObject(Register dst, const Object& object) {
     LoadObject(dst, object, /*movable_referent=*/true);
diff --git a/runtime/vm/compiler/assembler/assembler_x64.cc b/runtime/vm/compiler/assembler/assembler_x64.cc
index 3e02ea9..c089993 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.cc
+++ b/runtime/vm/compiler/assembler/assembler_x64.cc
@@ -1228,6 +1228,10 @@
   movq(dst, Address(THR, target::Thread::isolate_offset()));
 }
 
+void Assembler::LoadIsolateGroup(Register dst) {
+  movq(dst, Address(THR, target::Thread::isolate_group_offset()));
+}
+
 void Assembler::LoadDispatchTable(Register dst) {
   movq(dst, Address(THR, target::Thread::dispatch_table_array_offset()));
 }
@@ -1922,13 +1926,13 @@
                                      JumpDistance distance) {
   ASSERT(cid > 0);
   const intptr_t shared_table_offset =
-      target::Isolate::shared_class_table_offset();
+      target::IsolateGroup::shared_class_table_offset();
   const intptr_t table_offset =
       target::SharedClassTable::class_heap_stats_table_offset();
   const intptr_t class_offset = target::ClassTable::ClassOffsetFor(cid);
 
   Register temp_reg = TMP;
-  LoadIsolate(temp_reg);
+  LoadIsolateGroup(temp_reg);
   movq(temp_reg, Address(temp_reg, shared_table_offset));
   movq(temp_reg, Address(temp_reg, table_offset));
   cmpb(Address(temp_reg, class_offset), Immediate(0));
diff --git a/runtime/vm/compiler/assembler/assembler_x64.h b/runtime/vm/compiler/assembler/assembler_x64.h
index 1295e25..08f870b 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.h
+++ b/runtime/vm/compiler/assembler/assembler_x64.h
@@ -733,6 +733,7 @@
   }
 
   void LoadIsolate(Register dst);
+  void LoadIsolateGroup(Register dst);
   void LoadDispatchTable(Register dst);
   void LoadObject(Register dst, const Object& obj);
   void LoadUniqueObject(Register dst, const Object& obj);
diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc
index e83ce88..eeb7cd7 100644
--- a/runtime/vm/compiler/jit/compiler.cc
+++ b/runtime/vm/compiler/jit/compiler.cc
@@ -326,7 +326,6 @@
   CodePtr FinalizeCompilation(compiler::Assembler* assembler,
                               FlowGraphCompiler* graph_compiler,
                               FlowGraph* flow_graph);
-  void CheckIfBackgroundCompilerIsBeingStopped(bool optimizing_compiler);
 
   ParsedFunction* parsed_function_;
   const bool optimized_;
@@ -472,18 +471,6 @@
   return code.ptr();
 }
 
-void CompileParsedFunctionHelper::CheckIfBackgroundCompilerIsBeingStopped(
-    bool optimizing_compiler) {
-  ASSERT(Compiler::IsBackgroundCompilation());
-  if (optimizing_compiler) {
-    if (!isolate()->optimizing_background_compiler()->is_running()) {
-      // The background compiler is being stopped.
-      Compiler::AbortBackgroundCompilation(
-          DeoptId::kNone, "Optimizing Background compilation is being stopped");
-    }
-  }
-}
-
 // Return null if bailed out.
 CodePtr CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
   ASSERT(!FLAG_precompiled_mode);
@@ -614,10 +601,6 @@
               FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
         };
 
-        if (Compiler::IsBackgroundCompilation()) {
-          CheckIfBackgroundCompilerIsBeingStopped(optimized());
-        }
-
         // Grab write program_lock outside of potential safepoint, that lock
         // can't be waited for inside the safepoint.
         // Initially read lock was added to guard direct_subclasses field
@@ -1113,14 +1096,27 @@
   DISALLOW_COPY_AND_ASSIGN(BackgroundCompilationQueue);
 };
 
-BackgroundCompiler::BackgroundCompiler(Isolate* isolate, bool optimizing)
+class BackgroundCompilerTask : public ThreadPool::Task {
+ public:
+  explicit BackgroundCompilerTask(BackgroundCompiler* background_compiler)
+      : background_compiler_(background_compiler) {}
+  virtual ~BackgroundCompilerTask() {}
+
+ private:
+  virtual void Run() { background_compiler_->Run(); }
+
+  BackgroundCompiler* background_compiler_;
+
+  DISALLOW_COPY_AND_ASSIGN(BackgroundCompilerTask);
+};
+
+BackgroundCompiler::BackgroundCompiler(Isolate* isolate)
     : isolate_(isolate),
       queue_monitor_(),
       function_queue_(new BackgroundCompilationQueue()),
       done_monitor_(),
       running_(false),
       done_(true),
-      optimizing_(optimizing),
       disabled_depth_(0) {}
 
 // Fields all deleted in ::Stop; here clear them.
@@ -1141,19 +1137,18 @@
       HANDLESCOPE(thread);
       Function& function = Function::Handle(zone);
       {
-        MonitorLocker ml(&queue_monitor_);
+        SafepointMonitorLocker ml(&queue_monitor_);
         if (running_) {
           function = function_queue()->PeekFunction();
         }
       }
       while (!function.IsNull()) {
-        ASSERT(is_optimizing());
         Compiler::CompileOptimizedFunction(thread, function,
                                            Compiler::kNoOSRDeoptId);
 
         QueueElement* qelem = NULL;
         {
-          MonitorLocker ml(&queue_monitor_);
+          SafepointMonitorLocker ml(&queue_monitor_);
           if (!running_ || function_queue()->IsEmpty()) {
             // We are shutting down, queue was cleared.
             function = Function::null();
@@ -1162,8 +1157,7 @@
             const Function& old = Function::Handle(qelem->Function());
             // If an optimizable method is not optimized, put it back on
             // the background queue (unless it was passed to foreground).
-            if ((is_optimizing() && !old.HasOptimizedCode() &&
-                 old.IsOptimizable()) ||
+            if ((!old.HasOptimizedCode() && old.IsOptimizable()) ||
                 FLAG_stress_test_background_compilation) {
               if (old.is_background_optimizable() &&
                   Compiler::CanOptimizeFunction(thread, old)) {
@@ -1197,54 +1191,40 @@
   }
 }
 
-void BackgroundCompiler::Compile(const Function& function) {
-  ASSERT(Thread::Current()->IsMutatorThread());
-  MonitorLocker ml(&queue_monitor_);
-  ASSERT(running_);
-  if (function_queue()->ContainsObj(function)) {
-    return;
-  }
-  QueueElement* elem = new QueueElement(function);
-  function_queue()->Add(elem);
-  ml.Notify();
-}
-
-void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) {
-  function_queue_->VisitObjectPointers(visitor);
-}
-
-class BackgroundCompilerTask : public ThreadPool::Task {
- public:
-  explicit BackgroundCompilerTask(BackgroundCompiler* background_compiler)
-      : background_compiler_(background_compiler) {}
-  virtual ~BackgroundCompilerTask() {}
-
- private:
-  virtual void Run() { background_compiler_->Run(); }
-
-  BackgroundCompiler* background_compiler_;
-
-  DISALLOW_COPY_AND_ASSIGN(BackgroundCompilerTask);
-};
-
-void BackgroundCompiler::Start() {
+bool BackgroundCompiler::EnqueueCompilation(const Function& function) {
   Thread* thread = Thread::Current();
   ASSERT(thread->IsMutatorThread());
   ASSERT(!thread->IsAtSafepoint());
 
-  MonitorLocker ml(&done_monitor_);
-  if (running_ || !done_) return;
-  running_ = true;
-  done_ = false;
-  // If we ever wanted to run the BG compiler on the
-  // `IsolateGroup::mutator_pool()` we would need to ensure the BG compiler
-  // stops when it's idle - otherwise the [MutatorThreadPool]-based idle
-  // notification would not work anymore.
-  bool task_started = Dart::thread_pool()->Run<BackgroundCompilerTask>(this);
-  if (!task_started) {
-    running_ = false;
-    done_ = true;
+  SafepointMonitorLocker ml_done(&done_monitor_);
+  if (disabled_depth_ > 0) return false;
+  if (!running_ && done_) {
+    running_ = true;
+    done_ = false;
+    // If we ever wanted to run the BG compiler on the
+    // `IsolateGroup::mutator_pool()` we would need to ensure the BG compiler
+    // stops when it's idle - otherwise the [MutatorThreadPool]-based idle
+    // notification would not work anymore.
+    if (!Dart::thread_pool()->Run<BackgroundCompilerTask>(this)) {
+      running_ = false;
+      done_ = true;
+      return false;
+    }
   }
+
+  SafepointMonitorLocker ml(&queue_monitor_);
+  ASSERT(running_);
+  if (function_queue()->ContainsObj(function)) {
+    return true;
+  }
+  QueueElement* elem = new QueueElement(function);
+  function_queue()->Add(elem);
+  ml.NotifyAll();
+  return true;
+}
+
+void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) {
+  function_queue_->VisitObjectPointers(visitor);
 }
 
 void BackgroundCompiler::Stop() {
@@ -1252,22 +1232,30 @@
   ASSERT(thread->IsMutatorThread());
   ASSERT(!thread->IsAtSafepoint());
 
+  SafepointMonitorLocker ml_done(&done_monitor_);
+  StopLocked(thread, &ml_done);
+}
+
+void BackgroundCompiler::StopLocked(Thread* thread,
+                                    SafepointMonitorLocker* done_locker) {
   {
-    MonitorLocker ml(&queue_monitor_);
+    SafepointMonitorLocker ml(&queue_monitor_);
     running_ = false;
     function_queue_->Clear();
-    ml.Notify();  // Stop waiting for the queue.
+    ml.NotifyAll();  // Stop waiting for the queue.
   }
 
-  {
-    MonitorLocker ml_done(&done_monitor_);
-    while (!done_) {
-      ml_done.WaitWithSafepointCheck(thread);
-    }
+  while (!done_) {
+    done_locker->Wait();
   }
 }
 
 void BackgroundCompiler::Enable() {
+  Thread* thread = Thread::Current();
+  ASSERT(thread->IsMutatorThread());
+  ASSERT(!thread->IsAtSafepoint());
+
+  MonitorLocker ml_done(&done_monitor_);
   disabled_depth_--;
   if (disabled_depth_ < 0) {
     FATAL("Mismatched number of calls to BackgroundCompiler::Enable/Disable.");
@@ -1275,12 +1263,14 @@
 }
 
 void BackgroundCompiler::Disable() {
-  Stop();
-  disabled_depth_++;
-}
+  Thread* thread = Thread::Current();
+  ASSERT(thread->IsMutatorThread());
+  ASSERT(!thread->IsAtSafepoint());
 
-bool BackgroundCompiler::IsDisabled() {
-  return disabled_depth_ > 0;
+  SafepointMonitorLocker ml_done(&done_monitor_);
+  disabled_depth_++;
+  if (done_) return;
+  StopLocked(thread, &ml_done);
 }
 
 #else  // DART_PRECOMPILED_RUNTIME
@@ -1339,33 +1329,25 @@
   UNREACHABLE();
 }
 
-void BackgroundCompiler::Compile(const Function& function) {
+bool BackgroundCompiler::EnqueueCompilation(const Function& function) {
   UNREACHABLE();
+  return false;
 }
 
 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) {
   UNREACHABLE();
 }
 
-void BackgroundCompiler::Start() {
-  UNREACHABLE();
-}
-
 void BackgroundCompiler::Stop() {
   UNREACHABLE();
 }
 
 void BackgroundCompiler::Enable() {
-  UNREACHABLE();
+  // NOP
 }
 
 void BackgroundCompiler::Disable() {
-  UNREACHABLE();
-}
-
-bool BackgroundCompiler::IsDisabled() {
-  UNREACHABLE();
-  return true;
+  // NOP
 }
 
 #endif  // DART_PRECOMPILED_RUNTIME
diff --git a/runtime/vm/compiler/jit/compiler.h b/runtime/vm/compiler/jit/compiler.h
index 2e2d563..5ed55be 100644
--- a/runtime/vm/compiler/jit/compiler.h
+++ b/runtime/vm/compiler/jit/compiler.h
@@ -119,61 +119,33 @@
 // No OSR compilation in the background compiler.
 class BackgroundCompiler {
  public:
-  explicit BackgroundCompiler(Isolate* isolate, bool optimizing);
+  explicit BackgroundCompiler(Isolate* isolate);
   virtual ~BackgroundCompiler();
 
-  static void Start(Isolate* isolate) {
-    ASSERT(Thread::Current()->IsMutatorThread());
-    if (isolate->optimizing_background_compiler() != NULL) {
-      isolate->optimizing_background_compiler()->Start();
-    }
-  }
   static void Stop(Isolate* isolate) {
     ASSERT(Thread::Current()->IsMutatorThread());
-    if (isolate->optimizing_background_compiler() != NULL) {
-      isolate->optimizing_background_compiler()->Stop();
-    }
-  }
-  static void Enable(Isolate* isolate) {
-    ASSERT(Thread::Current()->IsMutatorThread());
-    if (isolate->optimizing_background_compiler() != NULL) {
-      isolate->optimizing_background_compiler()->Enable();
-    }
-  }
-  static void Disable(Isolate* isolate) {
-    ASSERT(Thread::Current()->IsMutatorThread());
-    if (isolate->optimizing_background_compiler() != NULL) {
-      isolate->optimizing_background_compiler()->Disable();
-    }
-  }
-  static bool IsDisabled(Isolate* isolate, bool optimizing_compiler) {
-    ASSERT(Thread::Current()->IsMutatorThread());
-    if (optimizing_compiler) {
-      if (isolate->optimizing_background_compiler() != NULL) {
-        return isolate->optimizing_background_compiler()->IsDisabled();
-      }
-    }
-    return false;
+    isolate->background_compiler()->Stop();
   }
 
-  // Call to compile (unoptimized or optimized) a function in the background,
-  // enters the function in the compilation queue.
-  void Compile(const Function& function);
+  // Enqueues a function to be compiled in the background.
+  //
+  // Return `true` if successful.
+  bool EnqueueCompilation(const Function& function);
 
   void VisitPointers(ObjectPointerVisitor* visitor);
 
   BackgroundCompilationQueue* function_queue() const { return function_queue_; }
   bool is_running() const { return running_; }
-  bool is_optimizing() const { return optimizing_; }
 
   void Run();
 
  private:
-  void Start();
+  friend class NoBackgroundCompilerScope;
+
   void Stop();
+  void StopLocked(Thread* thread, SafepointMonitorLocker* done_locker);
   void Enable();
   void Disable();
-  bool IsDisabled();
   bool IsRunning() { return !done_; }
 
   Isolate* isolate_;
@@ -184,13 +156,24 @@
   Monitor done_monitor_;    // Notify/wait that the thread is done.
   bool running_;            // While true, will try to read queue and compile.
   bool done_;               // True if the thread is done.
-  bool optimizing_;
 
   int16_t disabled_depth_;
 
   DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler);
 };
 
+class NoBackgroundCompilerScope : public StackResource {
+ public:
+  explicit NoBackgroundCompilerScope(Thread* thread)
+      : StackResource(thread), isolate_(thread->isolate()) {
+    isolate_->background_compiler()->Disable();
+  }
+  ~NoBackgroundCompilerScope() { isolate_->background_compiler()->Enable(); }
+
+ private:
+  Isolate* isolate_;
+};
+
 }  // namespace dart
 
 #endif  // RUNTIME_VM_COMPILER_JIT_COMPILER_H_
diff --git a/runtime/vm/compiler/runtime_api.h b/runtime/vm/compiler/runtime_api.h
index 6ef19fd..f135cff 100644
--- a/runtime/vm/compiler/runtime_api.h
+++ b/runtime/vm/compiler/runtime_api.h
@@ -1027,6 +1027,7 @@
   static word top_offset();
   static word end_offset();
   static word isolate_offset();
+  static word isolate_group_offset();
   static word field_table_values_offset();
   static word store_buffer_block_offset();
   static word call_to_runtime_entry_point_offset();
@@ -1151,13 +1152,17 @@
   static word current_tag_offset();
   static word user_tag_offset();
   static word cached_class_table_table_offset();
-  static word shared_class_table_offset();
   static word ic_miss_code_offset();
 #if !defined(PRODUCT)
   static word single_step_offset();
 #endif  // !defined(PRODUCT)
 };
 
+class IsolateGroup : public AllStatic {
+ public:
+  static word shared_class_table_offset();
+};
+
 class SharedClassTable : public AllStatic {
  public:
   static word class_heap_stats_table_offset();
diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h
index 35ef1e3..b7cf933 100644
--- a/runtime/vm/compiler/runtime_offsets_extracted.h
+++ b/runtime/vm/compiler/runtime_offsets_extracted.h
@@ -166,15 +166,15 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 36;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 40;
+    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 32;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 48;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 8;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 44;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -308,6 +308,7 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     728;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 40;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset = 744;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     64;
 static constexpr dart::compiler::target::word
@@ -698,15 +699,15 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 96;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -842,6 +843,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1464;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -1234,15 +1237,15 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 36;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 40;
+    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 32;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 48;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 8;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 44;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -1376,6 +1379,7 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     696;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 40;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset = 712;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     64;
 static constexpr dart::compiler::target::word
@@ -1763,15 +1767,15 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 96;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -1907,6 +1911,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1536;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -2302,15 +2308,15 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 96;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -2446,6 +2452,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1464;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -2840,15 +2848,15 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 96;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -2984,6 +2992,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1536;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -3377,14 +3387,14 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 36;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 40;
+    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 32;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 8;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -3518,6 +3528,7 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     728;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 40;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset = 744;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     64;
 static constexpr dart::compiler::target::word
@@ -3903,14 +3914,14 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -4046,6 +4057,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1464;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -4433,14 +4446,14 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 36;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 40;
+    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 32;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 8;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -4574,6 +4587,7 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     696;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 40;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset = 712;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     64;
 static constexpr dart::compiler::target::word
@@ -4956,14 +4970,14 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -5099,6 +5113,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1536;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -5489,14 +5505,14 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -5632,6 +5648,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1464;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -6021,14 +6039,14 @@
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 80;
+    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
 static constexpr dart::compiler::target::word
     Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -6164,6 +6182,8 @@
 static constexpr dart::compiler::target::word Thread_exit_through_ffi_offset =
     1536;
 static constexpr dart::compiler::target::word Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word Thread_field_table_values_offset =
     128;
 static constexpr dart::compiler::target::word
@@ -6562,9 +6582,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 20;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 36;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 40;
+    AOT_Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     20;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -6573,8 +6591,10 @@
     28;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 32;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 8;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    48;
+    44;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     16;
@@ -6725,6 +6745,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 728;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 40;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    744;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 64;
 static constexpr dart::compiler::target::word
@@ -7154,9 +7176,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -7165,8 +7185,10 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    96;
+    88;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -7317,6 +7339,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1464;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -7752,9 +7776,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -7763,8 +7785,10 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    96;
+    88;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -7915,6 +7939,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1536;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -8348,9 +8374,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -8359,8 +8383,10 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    96;
+    88;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -8511,6 +8537,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1464;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -8943,9 +8971,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -8954,8 +8980,10 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    96;
+    88;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -9106,6 +9134,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1536;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -9538,9 +9568,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 20;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 36;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 40;
+    AOT_Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     20;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -9549,6 +9577,8 @@
     28;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 32;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 8;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     16;
@@ -9699,6 +9729,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 728;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 40;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    744;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 64;
 static constexpr dart::compiler::target::word
@@ -10123,9 +10155,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -10134,6 +10164,8 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -10284,6 +10316,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1464;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -10714,9 +10748,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -10725,6 +10757,8 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -10875,6 +10909,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1536;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -11303,9 +11339,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -11314,6 +11348,8 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -11464,6 +11500,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1464;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1496;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
@@ -11891,9 +11929,7 @@
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
 static constexpr dart::compiler::target::word
-    AOT_Isolate_shared_class_table_offset = 72;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 80;
+    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -11902,6 +11938,8 @@
     56;
 static constexpr dart::compiler::target::word
     AOT_Isolate_cached_object_store_offset = 64;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_shared_class_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -12052,6 +12090,8 @@
 static constexpr dart::compiler::target::word
     AOT_Thread_exit_through_ffi_offset = 1536;
 static constexpr dart::compiler::target::word AOT_Thread_isolate_offset = 80;
+static constexpr dart::compiler::target::word AOT_Thread_isolate_group_offset =
+    1568;
 static constexpr dart::compiler::target::word
     AOT_Thread_field_table_values_offset = 128;
 static constexpr dart::compiler::target::word
diff --git a/runtime/vm/compiler/runtime_offsets_list.h b/runtime/vm/compiler/runtime_offsets_list.h
index 83c84f3..73a9fa5 100644
--- a/runtime/vm/compiler/runtime_offsets_list.h
+++ b/runtime/vm/compiler/runtime_offsets_list.h
@@ -127,12 +127,12 @@
   FIELD(ICData, owner_offset)                                                  \
   FIELD(ICData, state_bits_offset)                                             \
   FIELD(Int32x4, value_offset)                                                 \
-  FIELD(Isolate, shared_class_table_offset)                                    \
   FIELD(Isolate, cached_class_table_table_offset)                              \
   FIELD(Isolate, current_tag_offset)                                           \
   FIELD(Isolate, default_tag_offset)                                           \
   FIELD(Isolate, ic_miss_code_offset)                                          \
   FIELD(Isolate, cached_object_store_offset)                                   \
+  FIELD(IsolateGroup, shared_class_table_offset)                               \
   NOT_IN_PRODUCT(FIELD(Isolate, single_step_offset))                           \
   FIELD(Isolate, user_tag_offset)                                              \
   FIELD(LinkedHashMap, data_offset)                                            \
@@ -213,6 +213,7 @@
   FIELD(Thread, invoke_dart_code_stub_offset)                                  \
   FIELD(Thread, exit_through_ffi_offset)                                       \
   FIELD(Thread, isolate_offset)                                                \
+  FIELD(Thread, isolate_group_offset)                                          \
   FIELD(Thread, field_table_values_offset)                                     \
   FIELD(Thread, lazy_deopt_from_return_stub_offset)                            \
   FIELD(Thread, lazy_deopt_from_throw_stub_offset)                             \
diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc
index 9dcd004..d5d9a5e 100644
--- a/runtime/vm/compiler_test.cc
+++ b/runtime/vm/compiler_test.cc
@@ -89,17 +89,15 @@
   FLAG_background_compilation = true;
 #endif
   Isolate* isolate = thread->isolate();
-  BackgroundCompiler::Start(isolate);
-  isolate->optimizing_background_compiler()->Compile(func);
+  isolate->background_compiler()->EnqueueCompilation(func);
   Monitor* m = new Monitor();
   {
-    MonitorLocker ml(m);
+    SafepointMonitorLocker ml(m);
     while (!func.HasOptimizedCode()) {
-      ml.WaitWithSafepointCheck(thread, 1);
+      ml.Wait(1);
     }
   }
   delete m;
-  BackgroundCompiler::Stop(isolate);
 }
 
 ISOLATE_UNIT_TEST_CASE(CompileFunctionOnHelperThread) {
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 964497c..76e5444 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -1056,6 +1056,9 @@
 #else
 #error What architecture?
 #endif
+#if defined(DART_COMPRESSED_POINTERS)
+    buffer.AddString(" compressed");
+#endif
   }
 
   if (!Snapshot::IsAgnosticToNullSafety(kind)) {
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 50521d8..96d9b1b 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1820,7 +1820,6 @@
 #else
   DARTSCOPE(Thread::Current());
   API_TIMELINE_DURATION(T);
-  auto I = T->isolate();
   if (vm_snapshot_data_buffer != nullptr) {
     CHECK_NULL(vm_snapshot_data_size);
   }
@@ -1831,7 +1830,7 @@
   if (Api::IsError(state)) {
     return state;
   }
-  BackgroundCompiler::Stop(I);
+  NoBackgroundCompilerScope no_bg_compiler(T);
 
 #if defined(DEBUG)
   T->isolate_group()->heap()->CollectAllGarbage();
@@ -6532,9 +6531,11 @@
   return Api::NewError("%s: Cannot compile on an AOT runtime.", CURRENT_FUNC);
 #else
   DARTSCOPE(Thread::Current());
+
   // Prevent background compiler from running while code is being cleared and
   // adding new code.
-  BackgroundCompiler::Stop(Isolate::Current());
+  NoBackgroundCompilerScope no_bg_compiler(T);
+
   // We don't have mechanisms to change class-ids that are embedded in code and
   // ICData.
   ClassFinalizer::ClearAllCode();
@@ -6930,7 +6931,6 @@
 #else
   DARTSCOPE(Thread::Current());
   API_TIMELINE_DURATION(T);
-  Isolate* I = T->isolate();
   CHECK_NULL(vm_snapshot_data_buffer);
   CHECK_NULL(vm_snapshot_data_size);
   CHECK_NULL(vm_snapshot_instructions_buffer);
@@ -6944,7 +6944,9 @@
   if (Api::IsError(state)) {
     return state;
   }
-  BackgroundCompiler::Stop(I);
+
+  NoBackgroundCompilerScope no_bg_compiler(T);
+
   DropRegExpMatchCode(Z);
 
   ProgramVisitor::Dedup(T);
@@ -7031,7 +7033,7 @@
   // Kill off any auxiliary isolates before starting with deduping.
   KillNonMainIsolatesSlow(T, I);
 
-  BackgroundCompiler::Stop(I);
+  NoBackgroundCompilerScope no_bg_compiler(T);
   DropRegExpMatchCode(Z);
 
   ProgramVisitor::Dedup(T);
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index dc6463f..61be4a2 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -1629,7 +1629,7 @@
 #if defined(DART_PRECOMPILED_RUNTIME)
   UNREACHABLE();
 #else
-  BackgroundCompiler::Stop(isolate_);
+  NoBackgroundCompilerScope no_bg_compiler(Thread::Current());
   if (FLAG_trace_deoptimization) {
     THR_Print("Deopt for debugger\n");
   }
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 758d6de..84cb544 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -332,7 +332,8 @@
                            void* embedder_data,
                            ObjectStore* object_store,
                            Dart_IsolateFlags api_flags)
-    : embedder_data_(embedder_data),
+    : shared_class_table_(new SharedClassTable()),
+      embedder_data_(embedder_data),
       thread_pool_(),
       isolates_lock_(new SafepointRwLock()),
       isolates_(),
@@ -346,7 +347,6 @@
       api_state_(new ApiState()),
       thread_registry_(new ThreadRegistry()),
       safepoint_handler_(new SafepointHandler(this)),
-      shared_class_table_(new SharedClassTable()),
       object_store_(object_store),
       class_table_(new ClassTable(shared_class_table_.get())),
       store_buffer_(new StoreBuffer()),
@@ -432,7 +432,10 @@
 
 bool IsolateGroup::ContainsOnlyOneIsolate() {
   SafepointReadRwLocker ml(Thread::Current(), isolates_lock_.get());
-  return isolate_count_ == 1;
+  // We do allow 0 here as well, because the background compiler might call
+  // this method while the mutator thread is in shutdown procedure and
+  // unregistered itself already.
+  return isolate_count_ == 0 || isolate_count_ == 1;
 }
 
 void IsolateGroup::RunWithLockedGroup(std::function<void()> fun) {
@@ -969,7 +972,7 @@
 
   // Verify that all canonical instances are correctly setup in the
   // corresponding canonical tables.
-  BackgroundCompiler::Stop(this);
+  NoBackgroundCompilerScope no_bg_compiler(Thread::Current());
   group()->heap()->CollectAllGarbage();
   Thread* thread = Thread::Current();
   HeapIterationScope iteration(thread);
@@ -1666,7 +1669,6 @@
       current_tag_(UserTag::null()),
       default_tag_(UserTag::null()),
       ic_miss_code_(Code::null()),
-      shared_class_table_(isolate_group->shared_class_table()),
       field_table_(new FieldTable(/*isolate=*/this)),
       isolate_group_(isolate_group),
       isolate_object_store_(
@@ -1699,7 +1701,7 @@
       handler_info_cache_(),
       catch_entry_moves_cache_() {
   cached_object_store_ = object_store_shared_ptr_.get();
-  cached_class_table_table_ = class_table_->table();
+  cached_class_table_table_ = group()->class_table_->table();
   FlagsCopyFrom(api_flags);
   SetErrorsFatal(true);
   // TODO(asiva): A Thread is not available here, need to figure out
@@ -1714,8 +1716,7 @@
         "         See dartbug.com/30524 for more information.\n");
   }
 
-  NOT_IN_PRECOMPILED(optimizing_background_compiler_ =
-                         new BackgroundCompiler(this, /* optimizing = */ true));
+  NOT_IN_PRECOMPILED(background_compiler_ = new BackgroundCompiler(this));
 }
 
 #undef REUSABLE_HANDLE_SCOPE_INIT
@@ -1727,8 +1728,8 @@
   // RELEASE_ASSERT(program_reload_context_ == NULL);
 #endif  // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
 
-  delete optimizing_background_compiler_;
-  optimizing_background_compiler_ = nullptr;
+  delete background_compiler_;
+  background_compiler_ = nullptr;
 
 #if !defined(PRODUCT)
   delete debugger_;
@@ -2430,9 +2431,9 @@
 
 void Isolate::Shutdown() {
   ASSERT(this == Isolate::Current());
-  BackgroundCompiler::Stop(this);
-  delete optimizing_background_compiler_;
-  optimizing_background_compiler_ = nullptr;
+  NOT_IN_PRECOMPILED(BackgroundCompiler::Stop(this));
+  NOT_IN_PRECOMPILED(delete background_compiler_);
+  background_compiler_ = nullptr;
 
   Thread* thread = Thread::Current();
 
@@ -2595,9 +2596,6 @@
   if (background_compiler() != nullptr) {
     background_compiler()->VisitPointers(visitor);
   }
-  if (optimizing_background_compiler() != nullptr) {
-    optimizing_background_compiler()->VisitPointers(visitor);
-  }
 
 #if !defined(PRODUCT)
   // Visit objects in the debugger.
@@ -2706,8 +2704,7 @@
 
   {
     SafepointReadRwLocker ml(thread, isolates_lock_.get());
-    const bool only_one_isolate = isolates_.First() == isolates_.Last();
-    if (thread->IsMutatorThread() && only_one_isolate) {
+    if (thread->IsMutatorThread() && ContainsOnlyOneIsolate()) {
       single_current_mutator->Call();
       return;
     }
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index 3e87c33..ceca443 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -418,6 +418,11 @@
     return shared_class_table_.get();
   }
 
+  static intptr_t shared_class_table_offset() {
+    COMPILE_ASSERT(sizeof(IsolateGroup::shared_class_table_) == kWordSize);
+    return OFFSET_OF(IsolateGroup, shared_class_table_);
+  }
+
   void set_obfuscation_map(const char** map) { obfuscation_map_ = map; }
   const char** obfuscation_map() const { return obfuscation_map_; }
 
@@ -796,6 +801,10 @@
     return object_store_;
   }
 
+  // Accessed from generated code.
+  std::unique_ptr<SharedClassTable> shared_class_table_;
+  // End accessed from generated code.
+
   const char** obfuscation_map_ = nullptr;
 
   bool is_vm_isolate_heap_ = false;
@@ -845,7 +854,6 @@
 
   uint64_t id_ = 0;
 
-  std::unique_ptr<SharedClassTable> shared_class_table_;
   std::shared_ptr<ObjectStore> object_store_;
   std::shared_ptr<ClassTable> class_table_;
   std::unique_ptr<StoreBuffer> store_buffer_;
@@ -973,15 +981,6 @@
     return OFFSET_OF(Isolate, cached_class_table_table_);
   }
 
-  // Used during isolate creation to re-register isolate with right group.
-  void set_shared_class_table(SharedClassTable* table) {
-    shared_class_table_ = table;
-  }
-  // Used by the generated code.
-  static intptr_t shared_class_table_offset() {
-    return OFFSET_OF(Isolate, shared_class_table_);
-  }
-
   void set_object_store(ObjectStore* object_store);
   static intptr_t cached_object_store_offset() {
     return OFFSET_OF(Isolate, cached_object_store_);
@@ -1230,10 +1229,6 @@
     return background_compiler_;
   }
 
-  BackgroundCompiler* optimizing_background_compiler() const {
-    return optimizing_background_compiler_;
-  }
-
   intptr_t BlockClassFinalization() {
     ASSERT(defer_finalization_count_ >= 0);
     return defer_finalization_count_++;
@@ -1545,7 +1540,6 @@
   CodePtr ic_miss_code_;
   // Cached value of object_store_shared_ptr_, here for generated code access
   ObjectStore* cached_object_store_ = nullptr;
-  SharedClassTable* shared_class_table_ = nullptr;
   // Cached value of class_table_->table_, here for generated code access
   ClassPtr* cached_class_table_table_ = nullptr;
   FieldTable* field_table_ = nullptr;
@@ -1591,12 +1585,8 @@
 
   uint32_t isolate_flags_ = 0;
 
-  // Unoptimized background compilation.
   BackgroundCompiler* background_compiler_ = nullptr;
 
-  // Optimized background compilation.
-  BackgroundCompiler* optimizing_background_compiler_ = nullptr;
-
 // Fields that aren't needed in a product build go here with boolean flags at
 // the top.
 #if !defined(PRODUCT)
diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc
index 6e20c6e..f5b4498 100644
--- a/runtime/vm/isolate_reload.cc
+++ b/runtime/vm/isolate_reload.cc
@@ -664,8 +664,11 @@
       [&](Isolate* isolate) { number_of_isolates++; });
 
   // Disable the background compiler while we are performing the reload.
-  ForEachIsolate(
-      [&](Isolate* isolate) { BackgroundCompiler::Disable(isolate); });
+  ForEachIsolate([&](Isolate* isolate) {
+    // TODO(dartbug.com/36097): Once the BG compiler moves from Isolate to
+    // IsolateGroup this scope should cover most of this function.
+    NoBackgroundCompilerScope stop_bg_compiler(isolate->mutator_thread());
+  });
 
   // Wait for any concurrent marking tasks to finish and turn off the
   // concurrent marker during reload as we might be allocating new instances
@@ -874,10 +877,6 @@
     }
   }
 
-  // Re-enable the background compiler. Do this before propagating any errors.
-  ForEachIsolate(
-      [&](Isolate* isolate) { BackgroundCompiler::Enable(isolate); });
-
   // Reenable concurrent marking if it was initially on.
   if (old_concurrent_mark_flag) {
     heap->old_space()->set_enable_concurrent_mark(true);
diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc
index 32ed89f..2c78a12 100644
--- a/runtime/vm/runtime_entry.cc
+++ b/runtime/vm/runtime_entry.cc
@@ -2774,17 +2774,14 @@
 
   if (Compiler::CanOptimizeFunction(thread, function)) {
     if (FLAG_background_compilation) {
-      if (!BackgroundCompiler::IsDisabled(isolate,
-                                          /* optimizing_compiler = */ true) &&
-          function.is_background_optimizable()) {
-        // Ensure background compiler is running, if not start it.
-        BackgroundCompiler::Start(isolate);
+      if (function.is_background_optimizable() &&
+          isolate->background_compiler()->EnqueueCompilation(function)) {
         // Reduce the chance of triggering a compilation while the function is
         // being compiled in the background. INT32_MIN should ensure that it
         // takes long time to trigger a compilation.
         // Note that the background compilation queue rejects duplicate entries.
         function.SetUsageCounter(INT32_MIN);
-        isolate->optimizing_background_compiler()->Compile(function);
+
         // Continue in the same code.
         arguments.SetReturn(function);
         return;
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
index e67fa97..0df08ee 100644
--- a/runtime/vm/thread.h
+++ b/runtime/vm/thread.h
@@ -418,6 +418,9 @@
   // The isolate that this thread is operating on, or nullptr if none.
   Isolate* isolate() const { return isolate_; }
   static intptr_t isolate_offset() { return OFFSET_OF(Thread, isolate_); }
+  static intptr_t isolate_group_offset() {
+    return OFFSET_OF(Thread, isolate_group_);
+  }
 
   // The isolate group that this thread is operating on, or nullptr if none.
   IsolateGroup* isolate_group() const { return isolate_group_; }
diff --git a/samples/ffi/sqlite/example/main.dart b/samples/ffi/sqlite/example/main.dart
index 480ef42..59192ac 100644
--- a/samples/ffi/sqlite/example/main.dart
+++ b/samples/ffi/sqlite/example/main.dart
@@ -35,7 +35,7 @@
   for (Row r in result) {
     int id = r.readColumnAsInt("id");
     String name = r.readColumnByIndex(1);
-    String alternativeName = r.readColumn("alternative_name");
+    String? alternativeName = r.readColumn("alternative_name");
     dynamic multiTypedValue = r.readColumn("multi_typed_column");
     print("$id $name $alternativeName $multiTypedValue");
   }
@@ -54,7 +54,7 @@
   for (Row r in result) {
     int id = r.readColumnAsInt("id");
     String name = r.readColumnByIndex(1);
-    String alternativeName = r.readColumn("alternative_name");
+    String? alternativeName = r.readColumn("alternative_name");
     dynamic multiTypedValue = r.readColumn("multi_typed_column");
     print("$id $name $alternativeName $multiTypedValue");
     if (id == 2) {
diff --git a/samples/ffi/sqlite/lib/src/database.dart b/samples/ffi/sqlite/lib/src/database.dart
index b98bf25..9b0570c 100644
--- a/samples/ffi/sqlite/lib/src/database.dart
+++ b/samples/ffi/sqlite/lib/src/database.dart
@@ -28,7 +28,7 @@
   Database(String path,
       [int flags = Flags.SQLITE_OPEN_READWRITE | Flags.SQLITE_OPEN_CREATE]) {
     Pointer<Pointer<types.Database>> dbOut = calloc();
-    final pathC = Utf8.toUtf8(path);
+    final pathC = path.toNativeUtf8();
     final int resultCode =
         bindings.sqlite3_open_v2(pathC, dbOut, flags, nullptr);
     _database = dbOut.value;
@@ -64,7 +64,7 @@
   /// Execute a query, discarding any returned rows.
   void execute(String query) {
     Pointer<Pointer<Statement>> statementOut = calloc();
-    Pointer<Utf8> queryC = Utf8.toUtf8(query);
+    Pointer<Utf8> queryC = query.toNativeUtf8();
     int resultCode = bindings.sqlite3_prepare_v2(
         _database, queryC, -1, statementOut, nullptr);
     Pointer<Statement> statement = statementOut.value;
@@ -83,7 +83,7 @@
   /// Evaluate a query and return the resulting rows as an iterable.
   Result query(String query) {
     Pointer<Pointer<Statement>> statementOut = calloc();
-    Pointer<Utf8> queryC = Utf8.toUtf8(query);
+    Pointer<Utf8> queryC = query.toNativeUtf8();
     int resultCode = bindings.sqlite3_prepare_v2(
         _database, queryC, -1, statementOut, nullptr);
     Pointer<Statement> statement = statementOut.value;
@@ -99,7 +99,7 @@
     int columnCount = bindings.sqlite3_column_count(statement);
     for (int i = 0; i < columnCount; i++) {
       String columnName =
-          Utf8.fromUtf8(bindings.sqlite3_column_name(statement, i));
+          bindings.sqlite3_column_name(statement, i).toDartString();
       columnIndices[columnName] = i;
     }
 
@@ -107,9 +107,9 @@
   }
 
   SQLiteException _loadError(int errorCode) {
-    String errorMessage = Utf8.fromUtf8(bindings.sqlite3_errmsg(_database));
+    String errorMessage = bindings.sqlite3_errmsg(_database).toDartString();
     String errorCodeExplanation =
-        Utf8.fromUtf8(bindings.sqlite3_errstr(errorCode));
+        bindings.sqlite3_errstr(errorCode).toDartString();
     return SQLiteException(
         "$errorMessage (Code $errorCode: $errorCodeExplanation)");
   }
@@ -204,8 +204,9 @@
       dynamicType =
           _typeFromCode(bindings.sqlite3_column_type(_statement, columnIndex));
     } else {
-      dynamicType = _typeFromText(Utf8.fromUtf8(
-          bindings.sqlite3_column_decltype(_statement, columnIndex)));
+      dynamicType = _typeFromText(bindings
+          .sqlite3_column_decltype(_statement, columnIndex)
+          .toDartString());
     }
 
     switch (dynamicType) {
@@ -240,7 +241,7 @@
   /// Reads column [columnIndex] and converts to [Type.Text] if not text.
   String readColumnByIndexAsText(int columnIndex) {
     _checkIsCurrentRow();
-    return Utf8.fromUtf8(bindings.sqlite3_column_text(_statement, columnIndex));
+    return bindings.sqlite3_column_text(_statement, columnIndex).toDartString();
   }
 
   void _checkIsCurrentRow() {
diff --git a/samples/ffi/sqlite/pubspec.yaml b/samples/ffi/sqlite/pubspec.yaml
index 71d9d59..1effadc 100644
--- a/samples/ffi/sqlite/pubspec.yaml
+++ b/samples/ffi/sqlite/pubspec.yaml
@@ -6,6 +6,6 @@
 environment:
   sdk: '>=2.12.0-0 <3.0.0'
 dependencies:
-  ffi: ^0.2.0-nullsafety.1
+  ffi: ^0.3.1-nullsafety.0
 dev_dependencies:
   test: ^1.16.0-nullsafety.12
diff --git a/samples/ffi/sqlite/test/sqlite_test.dart b/samples/ffi/sqlite/test/sqlite_test.dart
index ef7666d..c0c9151 100644
--- a/samples/ffi/sqlite/test/sqlite_test.dart
+++ b/samples/ffi/sqlite/test/sqlite_test.dart
@@ -166,8 +166,8 @@
   });
   test("Utf8 unit test", () {
     final String test = 'Hasta Mañana';
-    final medium = Utf8.toUtf8(test);
-    expect(test, Utf8.fromUtf8(medium));
+    final medium = test.toNativeUtf8();
+    expect(test, medium.toDartString());
     calloc.free(medium);
   });
 }
diff --git a/samples_2/ffi/sqlite/lib/src/database.dart b/samples_2/ffi/sqlite/lib/src/database.dart
index 91bcfe6..d65724f 100644
--- a/samples_2/ffi/sqlite/lib/src/database.dart
+++ b/samples_2/ffi/sqlite/lib/src/database.dart
@@ -30,7 +30,7 @@
   Database(String path,
       [int flags = Flags.SQLITE_OPEN_READWRITE | Flags.SQLITE_OPEN_CREATE]) {
     Pointer<Pointer<types.Database>> dbOut = calloc();
-    final pathC = Utf8.toUtf8(path);
+    final pathC = path.toNativeUtf8();
     final int resultCode =
         bindings.sqlite3_open_v2(pathC, dbOut, flags, nullptr);
     _database = dbOut.value;
@@ -66,7 +66,7 @@
   /// Execute a query, discarding any returned rows.
   void execute(String query) {
     Pointer<Pointer<Statement>> statementOut = calloc();
-    Pointer<Utf8> queryC = Utf8.toUtf8(query);
+    Pointer<Utf8> queryC = query.toNativeUtf8();
     int resultCode = bindings.sqlite3_prepare_v2(
         _database, queryC, -1, statementOut, nullptr);
     Pointer<Statement> statement = statementOut.value;
@@ -85,7 +85,7 @@
   /// Evaluate a query and return the resulting rows as an iterable.
   Result query(String query) {
     Pointer<Pointer<Statement>> statementOut = calloc();
-    Pointer<Utf8> queryC = Utf8.toUtf8(query);
+    Pointer<Utf8> queryC = query.toNativeUtf8();
     int resultCode = bindings.sqlite3_prepare_v2(
         _database, queryC, -1, statementOut, nullptr);
     Pointer<Statement> statement = statementOut.value;
@@ -101,7 +101,7 @@
     int columnCount = bindings.sqlite3_column_count(statement);
     for (int i = 0; i < columnCount; i++) {
       String columnName =
-          Utf8.fromUtf8(bindings.sqlite3_column_name(statement, i));
+          bindings.sqlite3_column_name(statement, i).toDartString();
       columnIndices[columnName] = i;
     }
 
@@ -109,12 +109,12 @@
   }
 
   SQLiteException _loadError([int errorCode]) {
-    String errorMessage = Utf8.fromUtf8(bindings.sqlite3_errmsg(_database));
+    String errorMessage = bindings.sqlite3_errmsg(_database).toDartString();
     if (errorCode == null) {
       return SQLiteException(errorMessage);
     }
     String errorCodeExplanation =
-        Utf8.fromUtf8(bindings.sqlite3_errstr(errorCode));
+        bindings.sqlite3_errstr(errorCode).toDartString();
     return SQLiteException(
         "$errorMessage (Code $errorCode: $errorCodeExplanation)");
   }
@@ -214,8 +214,9 @@
       dynamicType =
           _typeFromCode(bindings.sqlite3_column_type(_statement, columnIndex));
     } else {
-      dynamicType = _typeFromText(Utf8.fromUtf8(
-          bindings.sqlite3_column_decltype(_statement, columnIndex)));
+      dynamicType = _typeFromText(bindings
+          .sqlite3_column_decltype(_statement, columnIndex)
+          .toDartString());
     }
 
     switch (dynamicType) {
@@ -251,7 +252,7 @@
   /// Reads column [columnIndex] and converts to [Type.Text] if not text.
   String readColumnByIndexAsText(int columnIndex) {
     _checkIsCurrentRow();
-    return Utf8.fromUtf8(bindings.sqlite3_column_text(_statement, columnIndex));
+    return bindings.sqlite3_column_text(_statement, columnIndex).toDartString();
   }
 
   void _checkIsCurrentRow() {
diff --git a/samples_2/ffi/sqlite/pubspec.yaml b/samples_2/ffi/sqlite/pubspec.yaml
index dcc5d40..16771df 100644
--- a/samples_2/ffi/sqlite/pubspec.yaml
+++ b/samples_2/ffi/sqlite/pubspec.yaml
@@ -6,6 +6,6 @@
 environment:
   sdk: '>=2.1.0 <3.0.0'
 dependencies:
-  ffi: ^0.1.3
+  ffi: ^0.3.1-nullsafety.0
 dev_dependencies:
   test: ^1.5.3
diff --git a/samples_2/ffi/sqlite/test/sqlite_test.dart b/samples_2/ffi/sqlite/test/sqlite_test.dart
index dffbe5b..91efe13 100644
--- a/samples_2/ffi/sqlite/test/sqlite_test.dart
+++ b/samples_2/ffi/sqlite/test/sqlite_test.dart
@@ -170,8 +170,8 @@
   });
   test("Utf8 unit test", () {
     final String test = 'Hasta Mañana';
-    final medium = Utf8.toUtf8(test);
-    expect(test, Utf8.fromUtf8(medium));
+    final medium = test.toNativeUtf8();
+    expect(test, medium.toDartString());
     calloc.free(medium);
   });
 }
diff --git a/sdk/lib/_http/http_impl.dart b/sdk/lib/_http/http_impl.dart
index eac06c4..e99a58d 100644
--- a/sdk/lib/_http/http_impl.dart
+++ b/sdk/lib/_http/http_impl.dart
@@ -2219,25 +2219,10 @@
       Future socketFuture = task.socket;
       final Duration? connectionTimeout = client.connectionTimeout;
       if (connectionTimeout != null) {
-        socketFuture = socketFuture.timeout(connectionTimeout, onTimeout: () {
-          _socketTasks.remove(task);
-          task.cancel();
-          return null;
-        });
+        socketFuture = socketFuture.timeout(connectionTimeout);
       }
       return socketFuture.then((socket) {
-        // When there is a timeout, there is a race in which the connectionTask
-        // Future won't be completed with an error before the socketFuture here
-        // is completed with 'null' by the onTimeout callback above. In this
-        // case, propagate a SocketException as specified by the
-        // HttpClient.connectionTimeout docs.
         _connecting--;
-        if (socket == null) {
-          assert(connectionTimeout != null);
-          throw new SocketException(
-              "HTTP connection timed out after ${connectionTimeout}, "
-              "host: ${host}, port: ${port}");
-        }
         socket.setOption(SocketOption.tcpNoDelay, true);
         var connection =
             new _HttpClientConnection(key, socket, client, false, context);
@@ -2258,6 +2243,20 @@
           return new _ConnectionInfo(connection, proxy);
         }
       }, onError: (error) {
+        // When there is a timeout, there is a race in which the connectionTask
+        // Future won't be completed with an error before the socketFuture here
+        // is completed with a TimeoutException by the onTimeout callback above.
+        // In this case, propagate a SocketException as specified by the
+        // HttpClient.connectionTimeout docs.
+        if (error is TimeoutException) {
+          assert(connectionTimeout != null);
+          _connecting--;
+          _socketTasks.remove(task);
+          task.cancel();
+          throw SocketException(
+              "HTTP connection timed out after ${connectionTimeout}, "
+              "host: ${host}, port: ${port}");
+        }
         _socketTasks.remove(task);
         _checkPending();
         throw error;
diff --git a/tests/ffi/regress_jump_to_frame_test.dart b/tests/ffi/regress_jump_to_frame_test.dart
index a3d9054..f47800b 100644
--- a/tests/ffi/regress_jump_to_frame_test.dart
+++ b/tests/ffi/regress_jump_to_frame_test.dart
@@ -40,7 +40,7 @@
 final Dart_PropagateError_DartType propagateError = () {
   final Pointer<_DartApi> dlapi = NativeApi.initializeApiDLData.cast();
   for (int i = 0; dlapi.ref.functions[i].name != nullptr; i++) {
-    final name = Utf8.fromUtf8(dlapi.ref.functions[i].name.cast<Utf8>());
+    final name = dlapi.ref.functions[i].name.cast<Utf8>().toDartString();
     if (name == 'Dart_PropagateError') {
       return dlapi.ref.functions[i].function
           .cast<NativeFunction<Dart_PropagateError_NativeType>>()
diff --git a/tests/ffi/structs_nnbd_workaround_test.dart b/tests/ffi/structs_nnbd_workaround_test.dart
index 2ed0dca..cf8f672 100644
--- a/tests/ffi/structs_nnbd_workaround_test.dart
+++ b/tests/ffi/structs_nnbd_workaround_test.dart
@@ -105,7 +105,7 @@
 
 void testUtf8() {
   final String test = 'Hasta Mañana';
-  final Pointer<Utf8> medium = Utf8.toUtf8(test);
-  Expect.equals(test, Utf8.fromUtf8(medium));
+  final Pointer<Utf8> medium = test.toNativeUtf8();
+  Expect.equals(test, medium.toDartString());
   calloc.free(medium);
 }
diff --git a/tests/ffi/structs_test.dart b/tests/ffi/structs_test.dart
index 4a5bb8c..77026a4 100644
--- a/tests/ffi/structs_test.dart
+++ b/tests/ffi/structs_test.dart
@@ -135,8 +135,8 @@
 
 void testUtf8() {
   final String test = 'Hasta Mañana';
-  final Pointer<Utf8> medium = Utf8.toUtf8(test);
-  Expect.equals(test, Utf8.fromUtf8(medium));
+  final Pointer<Utf8> medium = test.toNativeUtf8();
+  Expect.equals(test, medium.toDartString());
   calloc.free(medium);
 }
 
diff --git a/tests/ffi_2/regress_jump_to_frame_test.dart b/tests/ffi_2/regress_jump_to_frame_test.dart
index 9838443..65e8682 100644
--- a/tests/ffi_2/regress_jump_to_frame_test.dart
+++ b/tests/ffi_2/regress_jump_to_frame_test.dart
@@ -40,7 +40,7 @@
 final Dart_PropagateError_DartType propagateError = () {
   final Pointer<_DartApi> dlapi = NativeApi.initializeApiDLData.cast();
   for (int i = 0; dlapi.ref.functions[i].name != nullptr; i++) {
-    final name = Utf8.fromUtf8(dlapi.ref.functions[i].name.cast<Utf8>());
+    final name = dlapi.ref.functions[i].name.cast<Utf8>().toDartString();
     if (name == 'Dart_PropagateError') {
       return dlapi.ref.functions[i].function
           .cast<NativeFunction<Dart_PropagateError_NativeType>>()
diff --git a/tests/ffi_2/structs_test.dart b/tests/ffi_2/structs_test.dart
index 4a5bb8c..77026a4 100644
--- a/tests/ffi_2/structs_test.dart
+++ b/tests/ffi_2/structs_test.dart
@@ -135,8 +135,8 @@
 
 void testUtf8() {
   final String test = 'Hasta Mañana';
-  final Pointer<Utf8> medium = Utf8.toUtf8(test);
-  Expect.equals(test, Utf8.fromUtf8(medium));
+  final Pointer<Utf8> medium = test.toNativeUtf8();
+  Expect.equals(test, medium.toDartString());
   calloc.free(medium);
 }
 
diff --git a/tests/standalone/io/regress_44895.dart b/tests/standalone/io/regress_44895.dart
new file mode 100644
index 0000000..38c0110a
--- /dev/null
+++ b/tests/standalone/io/regress_44895.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2021, 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.
+
+import "dart:io";
+
+void main() {
+  final client = HttpClient();
+  client.connectionTimeout = Duration.zero;
+  // Should not throw a type error.
+  client.openUrl(
+    'get',
+    Uri.parse(
+      'https://localhost/',
+    ),
+  );
+}
diff --git a/tools/VERSION b/tools/VERSION
index 19aca10..a31069b 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 25
+PRERELEASE 26
 PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index b010541..e1800a4 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -1961,7 +1961,8 @@
             "language_2",
             "corelib_2",
             "lib_2",
-            "dartdevc_2"
+            "dartdevc_2",
+            "web_2"
           ]
         },
         {
@@ -2045,7 +2046,8 @@
             "language_2",
             "corelib_2",
             "lib_2",
-            "dartdevc_2"
+            "dartdevc_2",
+            "web_2"
           ]
         }
       ]
@@ -2090,7 +2092,8 @@
             "language",
             "corelib",
             "lib",
-            "dartdevc"
+            "dartdevc",
+            "web"
           ],
           "shards": 5,
           "fileset": "web_platform_nnbd"
@@ -2111,7 +2114,8 @@
             "language",
             "corelib",
             "lib",
-            "dartdevc"
+            "dartdevc",
+            "web"
           ]
         },
         {
@@ -2146,7 +2150,8 @@
             "language_2",
             "corelib_2",
             "lib_2",
-            "dartdevc_2"
+            "dartdevc_2",
+            "web_2"
           ]
         },
         {