Version 2.14.0-56.0.dev

Merge commit 'dbd48c3b0c0ac0ac77311c8710502d053d5c6b97' into 'dev'
diff --git a/DEPS b/DEPS
index 553bbaf..10f29bf 100644
--- a/DEPS
+++ b/DEPS
@@ -39,7 +39,7 @@
 
   # Checked-in SDK version. The checked-in SDK is a Dart SDK distribution in a
   # cipd package used to run Dart scripts in the build and test infrastructure.
-  "sdk_tag": "version:2.13.0-211.13.beta",
+  "sdk_tag": "version:2.12.0",
 
   # co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
   # hashes. It requires access to the dart-build-access group, which EngProd
diff --git a/pkg/analysis_server/bin/server.dart b/pkg/analysis_server/bin/server.dart
index a873eb1..7810101 100644
--- a/pkg/analysis_server/bin/server.dart
+++ b/pkg/analysis_server/bin/server.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/starter.dart';
 
 /// Create and run an analysis server.
diff --git a/pkg/analysis_server/test/lsp/initialization_test.dart b/pkg/analysis_server/test/lsp/initialization_test.dart
index a1b7707..9dbe5cc 100644
--- a/pkg/analysis_server/test/lsp/initialization_test.dart
+++ b/pkg/analysis_server/test/lsp/initialization_test.dart
@@ -566,6 +566,31 @@
     expect(server.contextManager.includedPaths, equals([projectFolderPath]));
   }
 
+  Future<void> test_nonProjectFiles_basicWorkspace() async {
+    final file1 = convertPath('/home/nonProject/file1.dart');
+    newFile(file1);
+
+    await initialize(allowEmptyRootUri: true);
+
+    // Because the file is not in a project, it should be added itself.
+    await openFile(Uri.file(file1), '');
+    expect(server.contextManager.includedPaths, equals([file1]));
+  }
+
+  Future<void> test_nonProjectFiles_bazelWorkspace() async {
+    final file1 = convertPath('/home/nonProject/file1.dart');
+    newFile(file1);
+
+    // Make /home a bazel workspace.
+    newFile(convertPath('/home/WORKSPACE'));
+
+    await initialize(allowEmptyRootUri: true);
+
+    // Because the file is not in a project, it should be added itself.
+    await openFile(Uri.file(file1), '');
+    expect(server.contextManager.includedPaths, equals([file1]));
+  }
+
   Future<void> test_onlyAnalyzeProjectsWithOpenFiles_multipleFiles() async {
     final file1 = join(projectFolderPath, 'file1.dart');
     final file1Uri = Uri.file(file1);
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index c50558f..3df1687 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -75,7 +75,8 @@
       HintCode(
           'ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER',
           "The argument type '{0}' can't be assigned to the parameter type "
-              "'{1} Function(Object)' or '{1} Function(Object, StackTrace)'.");
+              "'{1} Function(Object)' or '{1} Function(Object, StackTrace)'.",
+          hasPublishedDocs: true);
 
   /**
    * Users should not assign values marked `@doNotStore`.
@@ -1869,6 +1870,7 @@
       'INVALID_RETURN_TYPE_FOR_CATCH_ERROR',
       "A value of type '{0}' can't be returned by the 'onError' handler "
           "because it must be assignable to '{1}'.",
+      hasPublishedDocs: true,
       uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR');
 
   /**
@@ -1880,6 +1882,7 @@
       'INVALID_RETURN_TYPE_FOR_CATCH_ERROR',
       "The return type '{0}' isn't assignable to '{1}', as required by "
           "'Future.catchError'.",
+      hasPublishedDocs: true,
       uniqueName: 'RETURN_TYPE_INVALID_FOR_CATCH_ERROR');
 
   /**
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index d70224e..dcb61d0 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -1677,7 +1677,8 @@
       CompileTimeErrorCode(
           'CONFLICTING_GENERIC_INTERFACES',
           "The class '{0}' can't implement both '{1}' and '{2}' because the "
-              "type arguments are different.");
+              "type arguments are different.",
+          hasPublishedDocs: true);
 
   /**
    * 10.11 Class Member Conflicts: Let `C` be a class. It is a compile-time
@@ -2034,7 +2035,8 @@
           "A constant constructor can't call a non-constant super constructor "
               "of '{0}'.",
           correction: "Try calling a constant constructor in the superclass, "
-              "or removing the keyword 'const' from the constructor.");
+              "or removing the keyword 'const' from the constructor.",
+          hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -2133,7 +2135,8 @@
   static const CompileTimeErrorCode CONST_DEFERRED_CLASS = CompileTimeErrorCode(
       'CONST_DEFERRED_CLASS', "Deferred classes can't be created with 'const'.",
       correction: "Try using 'new' to create the instance, or "
-          "changing the import to not be deferred.");
+          "changing the import to not be deferred.",
+      hasPublishedDocs: true);
 
   /**
    * 16.12.2 Const: It is a compile-time error if evaluation of a constant
@@ -2320,7 +2323,8 @@
           correction:
               "Try initializing the variable without referencing members of "
               "the deferred library, or changing the import to not be "
-              "deferred.");
+              "deferred.",
+          hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -2423,7 +2427,8 @@
           "The type of a key in a constant map can't override the '==' "
               "operator, but the class '{0}' does.",
           correction: "Try using a different value for the key, or "
-              "removing the keyword 'const' from the map.");
+              "removing the keyword 'const' from the map.",
+          hasPublishedDocs: true);
 
   /**
    * Parameters:
@@ -2513,7 +2518,8 @@
           "The type of an element in a constant set can't override the '==' "
               "operator, but the type '{0}' does.",
           correction: "Try using a different value for the element, or "
-              "removing the keyword 'const' from the set.");
+              "removing the keyword 'const' from the set.",
+          hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -2993,7 +2999,8 @@
           correction:
               "Try adding either a show combinator listing the names you need "
               "to reference or a hide combinator listing all of the "
-              "extensions.");
+              "extensions.",
+          hasPublishedDocs: true);
 
   /**
    * Parameters:
@@ -3635,6 +3642,7 @@
           'SUBTYPE_OF_DEFERRED_CLASS', "Classes can't extend deferred classes.",
           correction: "Try specifying a different superclass, or "
               "removing the extends clause.",
+          hasPublishedDocs: true,
           uniqueName: 'EXTENDS_DEFERRED_CLASS');
 
   /**
@@ -4886,7 +4894,8 @@
       CompileTimeErrorCode(
           'FOR_IN_OF_INVALID_ELEMENT_TYPE',
           "The type '{0}' used in the 'for' loop must implement '{1}' with a "
-              "type argument that can be assigned to '{2}'.");
+              "type argument that can be assigned to '{2}'.",
+          hasPublishedDocs: true);
 
   /**
    * Parameters:
@@ -4968,7 +4977,8 @@
       CompileTimeErrorCode('FOR_IN_WITH_CONST_VARIABLE',
           "A for-in loop variable can't be a 'const'.",
           correction: "Try removing the 'const' modifier from the variable, or "
-              "use a different variable.");
+              "use a different variable.",
+          hasPublishedDocs: true);
 
   /**
    * It is a compile-time error if a generic function type is used as a bound
@@ -5215,6 +5225,7 @@
           correction: "Try specifying a different interface, "
               "removing the class from the list, or "
               "changing the import to not be deferred.",
+          hasPublishedDocs: true,
           uniqueName: 'IMPLEMENTS_DEFERRED_CLASS');
 
   /**
@@ -5952,7 +5963,8 @@
   // If you intend to use an instance of a class, then use the name of that class in place of the name of the enum.
   static const CompileTimeErrorCode INSTANTIATE_ENUM = CompileTimeErrorCode(
       'INSTANTIATE_ENUM', "Enums can't be instantiated.",
-      correction: "Try using one of the defined constants.");
+      correction: "Try using one of the defined constants.",
+      hasPublishedDocs: true);
 
   /**
    * It is a compile-time error for an instance creation `C<T1, .. Tk>(...)` or
@@ -6143,7 +6155,8 @@
           "Constant values from a deferred library can't be used as "
               "annotations.",
           correction: "Try removing the annotation, or "
-              "changing the import to not be deferred.");
+              "changing the import to not be deferred.",
+          hasPublishedDocs: true);
 
   /**
    * Parameters:
@@ -6518,7 +6531,8 @@
       CompileTimeErrorCode(
           'INVALID_IMPLEMENTATION_OVERRIDE',
           "'{1}.{0}' ('{2}') isn't a valid concrete implementation of "
-              "'{3}.{0}' ('{4}').");
+              "'{3}.{0}' ('{4}').",
+          hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -7616,7 +7630,8 @@
   // Reinstall the Dart or Flutter SDK.
   static const CompileTimeErrorCode MISSING_DART_LIBRARY = CompileTimeErrorCode(
       'MISSING_DART_LIBRARY', "Required library '{0}' is missing.",
-      correction: "Re-install the Dart or Flutter SDK.");
+      correction: "Re-install the Dart or Flutter SDK.",
+      hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -7814,7 +7829,8 @@
       MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER = CompileTimeErrorCode(
           'MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER',
           "The class doesn't have a concrete implementation of the "
-              "super-invoked member '{0}'.");
+              "super-invoked member '{0}'.",
+          hasPublishedDocs: true);
 
   /**
    * It's a compile-time error to apply a mixin to a class that doesn't
@@ -7859,6 +7875,7 @@
   static const CompileTimeErrorCode MIXIN_DEFERRED_CLASS = CompileTimeErrorCode(
       'SUBTYPE_OF_DEFERRED_CLASS', "Classes can't mixin deferred classes.",
       correction: "Try changing the import to not be deferred.",
+      hasPublishedDocs: true,
       uniqueName: 'MIXIN_DEFERRED_CLASS');
 
   static const CompileTimeErrorCode
@@ -7918,7 +7935,8 @@
   // If you intend to use an instance of a class, then use the name of that
   // class in place of the name of the mixin.
   static const CompileTimeErrorCode MIXIN_INSTANTIATE = CompileTimeErrorCode(
-      'MIXIN_INSTANTIATE', "Mixins can't be instantiated.");
+      'MIXIN_INSTANTIATE', "Mixins can't be instantiated.",
+      hasPublishedDocs: true);
 
   /**
    * Parameters:
@@ -8808,7 +8826,8 @@
               "expression.",
           correction:
               "Try re-writing the switch as a series of if statements, or "
-              "changing the import to not be deferred.");
+              "changing the import to not be deferred.",
+          hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -8912,7 +8931,8 @@
               "parameter value.",
           correction:
               "Try leaving the default as null and initializing the parameter "
-              "inside the function body.");
+              "inside the function body.",
+          hasPublishedDocs: true);
 
   /**
    * No parameters.
@@ -9026,6 +9046,7 @@
               "a 'const' list literal.",
           correction: "Try removing the keyword 'const' from the list literal "
               "or removing the keyword 'deferred' from the import.",
+          hasPublishedDocs: true,
           uniqueName: 'NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY');
 
   /**
@@ -9128,6 +9149,7 @@
           correction:
               "Try removing the keyword 'const' from the map literal or removing "
               "the keyword 'deferred' from the import.",
+          hasPublishedDocs: true,
           uniqueName: 'NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY');
 
   /**
@@ -9180,6 +9202,7 @@
           correction:
               "Try removing the keyword 'const' from the map literal or removing "
               "the keyword 'deferred' from the import.",
+          hasPublishedDocs: true,
           uniqueName: 'NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY');
 
   /**
@@ -11277,6 +11300,7 @@
           correction:
               "Try removing the keyword 'const' from the set literal or removing "
               "the keyword 'deferred' from the import.",
+          hasPublishedDocs: true,
           uniqueName: 'SET_ELEMENT_FROM_DEFERRED_LIBRARY');
 
   /**
@@ -11688,7 +11712,8 @@
           "The deferred type '{0}' can't be used in a declaration, cast, or "
               "type test.",
           correction: "Try using a different type, or "
-              "changing the import to not be deferred.");
+              "changing the import to not be deferred.",
+          hasPublishedDocs: true);
 
   /**
    * Parameters:
diff --git a/pkg/front_end/lib/src/fasta/type_inference/closure_context.dart b/pkg/front_end/lib/src/fasta/type_inference/closure_context.dart
index f8373f8..0bad19f 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/closure_context.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/closure_context.dart
@@ -157,6 +157,7 @@
 
   void _checkValidReturn(TypeInferrerImpl inferrer, DartType returnType,
       ReturnStatement statement, DartType expressionType) {
+    assert(!inferrer.isTopLevel);
     if (inferrer.isNonNullableByDefault) {
       if (statement.expression == null) {
         // It is a compile-time error if s is `return;`, unless T is void,
@@ -297,7 +298,7 @@
       // inferred the return type.
       _returnStatements.add(statement);
       _returnExpressionTypes.add(type);
-    } else {
+    } else if (!inferrer.isTopLevel) {
       _checkValidReturn(inferrer, _declaredReturnType, statement, type);
     }
   }
@@ -404,8 +405,10 @@
     }
 
     for (int i = 0; i < _returnStatements.length; ++i) {
-      _checkValidReturn(inferrer, inferredReturnType, _returnStatements[i],
-          _returnExpressionTypes[i]);
+      if (!inferrer.isTopLevel) {
+        _checkValidReturn(inferrer, inferredReturnType, _returnStatements[i],
+            _returnExpressionTypes[i]);
+      }
     }
 
     return _inferredReturnType =
@@ -426,9 +429,10 @@
     } else {
       returnType = _declaredReturnType;
     }
-    if (inferrer.library.isNonNullableByDefault &&
-        (!containsInvalidType(returnType) &&
-            returnType.isPotentiallyNonNullable) &&
+    if (!inferrer.isTopLevel &&
+        inferrer.library.isNonNullableByDefault &&
+        !containsInvalidType(returnType) &&
+        returnType.isPotentiallyNonNullable &&
         inferrer.flowAnalysis.isReachable) {
       Statement resultStatement =
           inferenceResult.hasChanged ? inferenceResult.statement : body;
@@ -503,6 +507,7 @@
 
   void _checkValidReturn(TypeInferrerImpl inferrer, DartType returnType,
       ReturnStatement statement, DartType expressionType) {
+    assert(!inferrer.isTopLevel);
     if (inferrer.isNonNullableByDefault) {
       assert(
           futureValueType != null, "Future value type has not been computed.");
@@ -675,7 +680,7 @@
       // inferred the return type.
       _returnStatements.add(statement);
       _returnExpressionTypes.add(type);
-    } else {
+    } else if (!inferrer.isTopLevel) {
       _checkValidReturn(inferrer, _declaredReturnType, statement, type);
     }
   }
@@ -805,9 +810,11 @@
       futureValueType =
           computeFutureValueType(inferrer.coreTypes, inferredType);
     }
-    for (int i = 0; i < _returnStatements.length; ++i) {
-      _checkValidReturn(inferrer, inferredType, _returnStatements[i],
-          _returnExpressionTypes[i]);
+    if (!inferrer.isTopLevel) {
+      for (int i = 0; i < _returnStatements.length; ++i) {
+        _checkValidReturn(inferrer, inferredType, _returnStatements[i],
+            _returnExpressionTypes[i]);
+      }
     }
 
     return _inferredReturnType =
@@ -829,9 +836,10 @@
       returnType = _declaredReturnType;
     }
     returnType = inferrer.typeSchemaEnvironment.flatten(returnType);
-    if (inferrer.library.isNonNullableByDefault &&
-        (!containsInvalidType(returnType) &&
-            returnType.isPotentiallyNonNullable) &&
+    if (!inferrer.isTopLevel &&
+        inferrer.library.isNonNullableByDefault &&
+        !containsInvalidType(returnType) &&
+        returnType.isPotentiallyNonNullable &&
         inferrer.flowAnalysis.isReachable) {
       Statement resultStatement =
           inferenceResult.hasChanged ? inferenceResult.statement : body;
diff --git a/pkg/front_end/testcases/general/issue38253.dart b/pkg/front_end/testcases/general/issue38253.dart
new file mode 100644
index 0000000..d80f398
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart
@@ -0,0 +1,11 @@
+// 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.
+
+var a = (){
+  g f(){
+    return;
+  }
+}
+
+main() {}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/general/issue38253.dart.outline.expect b/pkg/front_end/testcases/general/issue38253.dart.outline.expect
new file mode 100644
index 0000000..f88d457
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.outline.expect
@@ -0,0 +1,17 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253.dart:9:1: Error: Expected ';' after this.
+// }
+// ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:6:3: Error: 'g' isn't a type.
+//   g f(){
+//   ^
+//
+import self as self;
+
+static field () →* Null a;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue38253.dart.strong.expect b/pkg/front_end/testcases/general/issue38253.dart.strong.expect
new file mode 100644
index 0000000..3c75603
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.strong.expect
@@ -0,0 +1,24 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253.dart:9:1: Error: Expected ';' after this.
+// }
+// ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:6:3: Error: 'g' isn't a type.
+//   g f(){
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:7:5: Warning: Must explicitly return a value from a non-void function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () →* Null a = () → Null {
+  function f() → invalid-type {
+    return null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253.dart.strong.transformed.expect b/pkg/front_end/testcases/general/issue38253.dart.strong.transformed.expect
new file mode 100644
index 0000000..3c75603
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.strong.transformed.expect
@@ -0,0 +1,24 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253.dart:9:1: Error: Expected ';' after this.
+// }
+// ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:6:3: Error: 'g' isn't a type.
+//   g f(){
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:7:5: Warning: Must explicitly return a value from a non-void function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () →* Null a = () → Null {
+  function f() → invalid-type {
+    return null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue38253.dart.textual_outline.expect
new file mode 100644
index 0000000..6dd2343
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.textual_outline.expect
@@ -0,0 +1,6 @@
+var a = () {
+  g f() {
+    return;
+  }
+};
+main() {}
diff --git a/pkg/front_end/testcases/general/issue38253.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue38253.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..fd6ee5f
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.textual_outline_modelled.expect
@@ -0,0 +1,6 @@
+main() {}
+var a = () {
+  g f() {
+    return;
+  }
+};
diff --git a/pkg/front_end/testcases/general/issue38253.dart.weak.expect b/pkg/front_end/testcases/general/issue38253.dart.weak.expect
new file mode 100644
index 0000000..1a33eb7
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.weak.expect
@@ -0,0 +1,26 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253.dart:9:1: Error: Expected ';' after this.
+// }
+// ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:6:3: Error: 'g' isn't a type.
+//   g f(){
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () → Null a = () → Null {
+  function f() → invalid-type {
+    return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/issue38253.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+    return;
+    ^" in null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue38253.dart.weak.outline.expect
new file mode 100644
index 0000000..b9350a8
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.weak.outline.expect
@@ -0,0 +1,17 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253.dart:9:1: Error: Expected ';' after this.
+// }
+// ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:6:3: Error: 'g' isn't a type.
+//   g f(){
+//   ^
+//
+import self as self;
+
+static field () → Null a;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue38253.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue38253.dart.weak.transformed.expect
new file mode 100644
index 0000000..1a33eb7
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253.dart.weak.transformed.expect
@@ -0,0 +1,26 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253.dart:9:1: Error: Expected ';' after this.
+// }
+// ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:6:3: Error: 'g' isn't a type.
+//   g f(){
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () → Null a = () → Null {
+  function f() → invalid-type {
+    return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/issue38253.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+    return;
+    ^" in null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253b.dart b/pkg/front_end/testcases/general/issue38253b.dart
new file mode 100644
index 0000000..ccd1c28
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart
@@ -0,0 +1,15 @@
+// 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.
+
+var a = () {
+  g f1() {
+    return;
+  }
+
+  g f2() async {
+    return;
+  }
+};
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.outline.expect b/pkg/front_end/testcases/general/issue38253b.dart.outline.expect
new file mode 100644
index 0000000..a8c4ff9
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.outline.expect
@@ -0,0 +1,17 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253b.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:10:3: Error: 'g' isn't a type.
+//   g f2() {
+//   ^
+//
+import self as self;
+
+static field () →* Null a;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.strong.expect b/pkg/front_end/testcases/general/issue38253b.dart.strong.expect
new file mode 100644
index 0000000..7d768a3
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.strong.expect
@@ -0,0 +1,31 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253b.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:10:3: Error: 'g' isn't a type.
+//   g f2() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:7:5: Warning: Must explicitly return a value from a non-void function.
+//     return;
+//     ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:11:5: Warning: Must explicitly return a value from a non-void function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () →* Null a = () → Null {
+  function f1() → invalid-type {
+    return null;
+  }
+  function f2() → invalid-type {
+    return null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.strong.transformed.expect b/pkg/front_end/testcases/general/issue38253b.dart.strong.transformed.expect
new file mode 100644
index 0000000..7d768a3
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.strong.transformed.expect
@@ -0,0 +1,31 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253b.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:10:3: Error: 'g' isn't a type.
+//   g f2() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:7:5: Warning: Must explicitly return a value from a non-void function.
+//     return;
+//     ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:11:5: Warning: Must explicitly return a value from a non-void function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () →* Null a = () → Null {
+  function f1() → invalid-type {
+    return null;
+  }
+  function f2() → invalid-type {
+    return null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue38253b.dart.textual_outline.expect
new file mode 100644
index 0000000..8fdaf50
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.textual_outline.expect
@@ -0,0 +1,10 @@
+var a = () {
+  g f1() {
+    return;
+  }
+
+  g f2() async {
+    return;
+  }
+};
+main() {}
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue38253b.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..7285d54
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.textual_outline_modelled.expect
@@ -0,0 +1,10 @@
+main() {}
+var a = () {
+  g f1() {
+    return;
+  }
+
+  g f2() async {
+    return;
+  }
+};
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.weak.expect b/pkg/front_end/testcases/general/issue38253b.dart.weak.expect
new file mode 100644
index 0000000..413a243
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.weak.expect
@@ -0,0 +1,35 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253b.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:10:3: Error: 'g' isn't a type.
+//   g f2() async {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+//     return;
+//     ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:11:5: Error: A value must be explicitly returned from a non-void async function.
+//     return;
+//     ^
+//
+import self as self;
+
+static field () → Null a = () → Null {
+  function f1() → invalid-type {
+    return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/issue38253b.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+    return;
+    ^" in null;
+  }
+  function f2() → invalid-type async {
+    return let final Never #t2 = invalid-expression "pkg/front_end/testcases/general/issue38253b.dart:11:5: Error: A value must be explicitly returned from a non-void async function.
+    return;
+    ^" in null;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue38253b.dart.weak.outline.expect
new file mode 100644
index 0000000..8240032
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.weak.outline.expect
@@ -0,0 +1,17 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253b.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:10:3: Error: 'g' isn't a type.
+//   g f2() async {
+//   ^
+//
+import self as self;
+
+static field () → Null a;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue38253b.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue38253b.dart.weak.transformed.expect
new file mode 100644
index 0000000..74a5ad5
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253b.dart.weak.transformed.expect
@@ -0,0 +1,61 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253b.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:10:3: Error: 'g' isn't a type.
+//   g f2() async {
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+//     return;
+//     ^
+//
+// pkg/front_end/testcases/general/issue38253b.dart:11:5: Error: A value must be explicitly returned from a non-void async function.
+//     return;
+//     ^
+//
+import self as self;
+import "dart:async" as asy;
+import "dart:core" as core;
+
+static field () → Null a = () → Null {
+  function f1() → invalid-type {
+    return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/issue38253b.dart:7:5: Error: A value must be explicitly returned from a non-void function.
+    return;
+    ^" in null;
+  }
+  function f2() → invalid-type /* originally async */ {
+    final asy::_Future<dynamic> :async_future = new asy::_Future::•<dynamic>();
+    core::bool* :is_sync = false;
+    FutureOr<dynamic>? :return_value;
+    (dynamic) → dynamic :async_op_then;
+    (core::Object, core::StackTrace) → dynamic :async_op_error;
+    core::int :await_jump_var = 0;
+    dynamic :await_ctx_var;
+    function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding 
+      try {
+        #L1:
+        {
+          :return_value = let final Never #t2 = invalid-expression "pkg/front_end/testcases/general/issue38253b.dart:11:5: Error: A value must be explicitly returned from a non-void async function.
+    return;
+    ^" in null;
+          break #L1;
+        }
+        asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync);
+        return;
+      }
+      on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+        asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+      }
+    :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+    :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+    :async_op.call();
+    :is_sync = true;
+    return :async_future;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253c.dart b/pkg/front_end/testcases/general/issue38253c.dart
new file mode 100644
index 0000000..dfe02da
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart
@@ -0,0 +1,16 @@
+// 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.
+
+var a = () {
+  g f1() {}
+  g f2() async {}
+  int f3() {}
+  Future<int> f4() async {}
+};
+
+var b = (f) async => await f;
+
+var c = (f) => f;
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.outline.expect b/pkg/front_end/testcases/general/issue38253c.dart.outline.expect
new file mode 100644
index 0000000..16b563d
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.outline.expect
@@ -0,0 +1,17 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253c.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:7:3: Error: 'g' isn't a type.
+//   g f2() async {}
+//   ^
+//
+import self as self;
+
+static field () →* Null a;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.strong.expect b/pkg/front_end/testcases/general/issue38253c.dart.strong.expect
new file mode 100644
index 0000000..c43866a1
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.strong.expect
@@ -0,0 +1,23 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253c.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:7:3: Error: 'g' isn't a type.
+//   g f2() async {}
+//   ^
+//
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+static field () →* Null a = () → Null {
+  function f1() → invalid-type {}
+  function f2() → invalid-type async {}
+  function f3() → core::int* {}
+  function f4() → asy::Future<core::int*>* async {}
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.strong.transformed.expect b/pkg/front_end/testcases/general/issue38253c.dart.strong.transformed.expect
new file mode 100644
index 0000000..eb54dc9
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.strong.transformed.expect
@@ -0,0 +1,69 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253c.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:7:3: Error: 'g' isn't a type.
+//   g f2() async {}
+//   ^
+//
+import self as self;
+import "dart:async" as asy;
+import "dart:core" as core;
+
+static field () →* Null a = () → Null {
+  function f1() → invalid-type {}
+  function f2() → invalid-type /* originally async */ {
+    final asy::_Future<dynamic>* :async_future = new asy::_Future::•<dynamic>();
+    core::bool* :is_sync = false;
+    FutureOr<dynamic>* :return_value;
+    (dynamic) →* dynamic :async_op_then;
+    (core::Object*, core::StackTrace*) →* dynamic :async_op_error;
+    core::int* :await_jump_var = 0;
+    dynamic :await_ctx_var;
+    function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding 
+      try {
+        #L1:
+        {}
+        asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync);
+        return;
+      }
+      on dynamic catch(dynamic exception, core::StackTrace* stack_trace) {
+        asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+      }
+    :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+    :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+    :async_op.call();
+    :is_sync = true;
+    return :async_future;
+  }
+  function f3() → core::int* {}
+  function f4() → asy::Future<core::int*>* /* originally async */ {
+    final asy::_Future<core::int*>* :async_future = new asy::_Future::•<core::int*>();
+    core::bool* :is_sync = false;
+    FutureOr<core::int*>* :return_value;
+    (dynamic) →* dynamic :async_op_then;
+    (core::Object*, core::StackTrace*) →* dynamic :async_op_error;
+    core::int* :await_jump_var = 0;
+    dynamic :await_ctx_var;
+    function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding 
+      try {
+        #L2:
+        {}
+        asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync);
+        return;
+      }
+      on dynamic catch(dynamic exception, core::StackTrace* stack_trace) {
+        asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+      }
+    :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+    :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+    :async_op.call();
+    :is_sync = true;
+    return :async_future;
+  }
+};
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue38253c.dart.textual_outline.expect
new file mode 100644
index 0000000..cc0555e
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.textual_outline.expect
@@ -0,0 +1,9 @@
+var a = () {
+  g f1() {}
+  g f2() async {}
+  int f3() {}
+  Future<int> f4() async {}
+};
+var b = (f) async => await f;
+var c = (f) => f;
+main() {}
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue38253c.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..f18dfd9
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.textual_outline_modelled.expect
@@ -0,0 +1,9 @@
+main() {}
+var a = () {
+  g f1() {}
+  g f2() async {}
+  int f3() {}
+  Future<int> f4() async {}
+};
+var b = (f) async => await f;
+var c = (f) => f;
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.weak.expect b/pkg/front_end/testcases/general/issue38253c.dart.weak.expect
new file mode 100644
index 0000000..cd01b2b
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.weak.expect
@@ -0,0 +1,41 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253c.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:7:3: Error: 'g' isn't a type.
+//   g f2() async {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:8:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+//   int f3() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:9:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+//   Future<int> f4() async {}
+//   ^
+//
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+static field () → Null a = () → Null {
+  function f1() → invalid-type {}
+  function f2() → invalid-type async {}
+  function f3() → core::int {
+    return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/issue38253c.dart:8:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+  int f3() {}
+  ^" in null;
+  }
+  function f4() → asy::Future<core::int> async {
+    return let final Never #t2 = invalid-expression "pkg/front_end/testcases/general/issue38253c.dart:9:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+  Future<int> f4() async {}
+  ^" in null;
+  }
+};
+static field (dynamic) → asy::Future<dynamic> b = (dynamic f) → asy::Future<dynamic> async => await f;
+static field (dynamic) → dynamic c = (dynamic f) → dynamic => f;
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue38253c.dart.weak.outline.expect
new file mode 100644
index 0000000..68cdd6d
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.weak.outline.expect
@@ -0,0 +1,20 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253c.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:7:3: Error: 'g' isn't a type.
+//   g f2() async {}
+//   ^
+//
+import self as self;
+import "dart:async" as asy;
+
+static field () → Null a;
+static field (dynamic) → asy::Future<dynamic> b;
+static field (dynamic) → dynamic c;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue38253c.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue38253c.dart.weak.transformed.expect
new file mode 100644
index 0000000..34a47d3
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue38253c.dart.weak.transformed.expect
@@ -0,0 +1,116 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue38253c.dart:6:3: Error: 'g' isn't a type.
+//   g f1() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:7:3: Error: 'g' isn't a type.
+//   g f2() async {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:8:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+//   int f3() {}
+//   ^
+//
+// pkg/front_end/testcases/general/issue38253c.dart:9:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+//   Future<int> f4() async {}
+//   ^
+//
+import self as self;
+import "dart:async" as asy;
+import "dart:core" as core;
+
+static field () → Null a = () → Null {
+  function f1() → invalid-type {}
+  function f2() → invalid-type /* originally async */ {
+    final asy::_Future<dynamic> :async_future = new asy::_Future::•<dynamic>();
+    core::bool* :is_sync = false;
+    FutureOr<dynamic>? :return_value;
+    (dynamic) → dynamic :async_op_then;
+    (core::Object, core::StackTrace) → dynamic :async_op_error;
+    core::int :await_jump_var = 0;
+    dynamic :await_ctx_var;
+    function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding 
+      try {
+        #L1:
+        {}
+        asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync);
+        return;
+      }
+      on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+        asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+      }
+    :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+    :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+    :async_op.call();
+    :is_sync = true;
+    return :async_future;
+  }
+  function f3() → core::int {
+    return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/issue38253c.dart:8:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+  int f3() {}
+  ^" in null;
+  }
+  function f4() → asy::Future<core::int> /* originally async */ {
+    final asy::_Future<core::int> :async_future = new asy::_Future::•<core::int>();
+    core::bool* :is_sync = false;
+    FutureOr<core::int>? :return_value;
+    (dynamic) → dynamic :async_op_then;
+    (core::Object, core::StackTrace) → dynamic :async_op_error;
+    core::int :await_jump_var = 0;
+    dynamic :await_ctx_var;
+    function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding 
+      try {
+        #L2:
+        {
+          :return_value = let final Never #t2 = invalid-expression "pkg/front_end/testcases/general/issue38253c.dart:9:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null.
+  Future<int> f4() async {}
+  ^" in null;
+          break #L2;
+        }
+        asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync);
+        return;
+      }
+      on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+        asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+      }
+    :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+    :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+    :async_op.call();
+    :is_sync = true;
+    return :async_future;
+  }
+};
+static field (dynamic) → asy::Future<dynamic> b = (dynamic f) → asy::Future<dynamic> /* originally async */ {
+  final asy::_Future<dynamic> :async_future = new asy::_Future::•<dynamic>();
+  core::bool* :is_sync = false;
+  FutureOr<dynamic>? :return_value;
+  (dynamic) → dynamic :async_op_then;
+  (core::Object, core::StackTrace) → dynamic :async_op_error;
+  core::int :await_jump_var = 0;
+  dynamic :await_ctx_var;
+  dynamic :saved_try_context_var0;
+  function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding 
+    try {
+      #L3:
+      {
+        [yield] let dynamic #t3 = asy::_awaitHelper(f, :async_op_then, :async_op_error, :async_op) in null;
+        :return_value = :result;
+        break #L3;
+      }
+      asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync);
+      return;
+    }
+    on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+      asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+    }
+  :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+  :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+  :async_op.call();
+  :is_sync = true;
+  return :async_future;
+};
+static field (dynamic) → dynamic c = (dynamic f) → dynamic => f;
+static method main() → dynamic {}
diff --git a/pkg/kernel/bin/count_breakdown.dart b/pkg/kernel/bin/count_breakdown.dart
index 13dd0737..839ab42 100755
--- a/pkg/kernel/bin/count_breakdown.dart
+++ b/pkg/kernel/bin/count_breakdown.dart
@@ -3,8 +3,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 import 'package:kernel/kernel.dart';
 import 'package:kernel/src/tool/command_line_util.dart';
@@ -32,8 +30,7 @@
   Map<String, int> _typeCounts = <String, int>{};
   defaultNode(Node node) {
     String key = node.runtimeType.toString();
-    _typeCounts[key] ??= 0;
-    _typeCounts[key]++;
+    _typeCounts[key] = (_typeCounts[key] ??= 0) + 1;
     super.defaultNode(node);
   }
 
@@ -43,8 +40,8 @@
       data.add([type, count]);
     });
     data.sort((a, b) {
-      int aCount = a[1];
-      int bCount = b[1];
+      int aCount = a[1] as int;
+      int bCount = b[1] as int;
       return bCount - aCount;
     });
     for (var entry in data) {
diff --git a/pkg/kernel/bin/dump.dart b/pkg/kernel/bin/dump.dart
index c95a4e5..0c3ab47 100755
--- a/pkg/kernel/bin/dump.dart
+++ b/pkg/kernel/bin/dump.dart
@@ -3,8 +3,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:kernel/kernel.dart';
diff --git a/pkg/kernel/bin/size_breakdown.dart b/pkg/kernel/bin/size_breakdown.dart
index dc4cd9b..af98f8a 100755
--- a/pkg/kernel/bin/size_breakdown.dart
+++ b/pkg/kernel/bin/size_breakdown.dart
@@ -3,8 +3,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:kernel/kernel.dart';
@@ -64,9 +62,9 @@
     linkTableSize += byteOffset;
   }
 
-  Map<Uri, Source> readUriToSource({bool readCoverage}) {
+  Map<Uri, Source> readUriToSource({required bool readCoverage}) {
     uriToSourceSize -= byteOffset;
-    var result = super.readUriToSource(readCoverage: readCoverage);
+    Map<Uri, Source> result = super.readUriToSource(readCoverage: readCoverage);
     uriToSourceSize += byteOffset;
     return result;
   }
@@ -104,7 +102,7 @@
     print("Constant table: ${_bytesToReadable(constantTableSize)}");
     print("");
     for (Uri uri in librarySizes.keys) {
-      print("Library '$uri': ${_bytesToReadable(librarySizes[uri])}.");
+      print("Library '$uri': ${_bytesToReadable(librarySizes[uri]!)}.");
     }
   }
 }
diff --git a/pkg/kernel/bin/split.dart b/pkg/kernel/bin/split.dart
index 61d5f0c..e3c99e8 100755
--- a/pkg/kernel/bin/split.dart
+++ b/pkg/kernel/bin/split.dart
@@ -3,8 +3,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:async';
 import 'dart:io';
 
diff --git a/pkg/kernel/bin/type_check.dart b/pkg/kernel/bin/type_check.dart
index 5c41244..5c3ef65 100755
--- a/pkg/kernel/bin/type_check.dart
+++ b/pkg/kernel/bin/type_check.dart
@@ -3,8 +3,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:kernel/error_formatter.dart';
diff --git a/pkg/kernel/lib/error_formatter.dart b/pkg/kernel/lib/error_formatter.dart
index aab719e..5640a9e 100644
--- a/pkg/kernel/lib/error_formatter.dart
+++ b/pkg/kernel/lib/error_formatter.dart
@@ -3,8 +3,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:kernel/kernel.dart';
 import 'package:kernel/naive_type_checker.dart';
 import 'package:kernel/text/ast_to_text.dart';
@@ -36,7 +34,7 @@
         ? where
         : _findEnclosingMember(where);
     String sourceLocation = '<unknown source>';
-    String sourceLine = null;
+    String? sourceLine = null;
 
     // Try finding original source line.
     final int fileOffset = _findFileOffset(where);
@@ -44,11 +42,12 @@
       final Uri fileUri = _fileUriOf(context);
 
       final Component component = context.enclosingComponent;
-      final Source source = component.uriToSource[fileUri];
-      final Location location = component.getLocation(fileUri, fileOffset);
-      final int lineStart = source.lineStarts[location.line - 1];
-      final int lineEnd = (location.line < source.lineStarts.length)
-          ? source.lineStarts[location.line]
+      final Source source = component.uriToSource[fileUri]!;
+      final Location location = component.getLocation(fileUri, fileOffset)!;
+      final List<int> lineStarts = source.lineStarts!;
+      final int lineStart = lineStarts[location.line - 1];
+      final int lineEnd = (location.line < lineStarts.length)
+          ? lineStarts[location.line]
           : (source.source.length - 1);
       if (lineStart < source.source.length &&
           lineEnd < source.source.length &&
@@ -66,7 +65,7 @@
       name = context.name;
     } else if (context is Procedure || context is Constructor) {
       final dynamic parent = context.parent;
-      final String parentName =
+      final String? parentName =
           parent is Class ? parent.name : (parent as Library).name;
       name = "${parentName}::${context.name.text}";
     } else {
@@ -108,7 +107,7 @@
   static String _realign(String str, [String prefix = '|   ']) =>
       str.trimRight().replaceAll('\n', '\n${prefix}');
 
-  static int _findFileOffset(TreeNode context) {
+  static int _findFileOffset(TreeNode? context) {
     while (context != null && context.fileOffset == TreeNode.noOffset) {
       context = context.parent;
     }
@@ -117,9 +116,9 @@
   }
 
   static Member _findEnclosingMember(TreeNode n) {
-    TreeNode context = n;
+    TreeNode? context = n;
     while (context is! Member) {
-      context = context.parent;
+      context = context!.parent;
     }
     return context;
   }
diff --git a/pkg/kernel/lib/external_name.dart b/pkg/kernel/lib/external_name.dart
index 2531780..f491275 100644
--- a/pkg/kernel/lib/external_name.dart
+++ b/pkg/kernel/lib/external_name.dart
@@ -2,14 +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.external_name;
 
 import 'ast.dart';
 
 /// Returns external (native) name of given [Member].
-String getExternalName(Member procedure) {
+String? getExternalName(Member procedure) {
   // Native procedures are marked as external and have an annotation,
   // which looks like this:
   //
@@ -22,7 +20,7 @@
     return null;
   }
   for (final Expression annotation in procedure.annotations) {
-    final String value = _getExternalNameValue(annotation);
+    final String? value = _getExternalNameValue(annotation);
     if (value != null) {
       return value;
     }
@@ -34,7 +32,7 @@
 List<String> getNativeExtensionUris(Library library) {
   final List<String> uris = <String>[];
   for (Expression annotation in library.annotations) {
-    final String value = _getExternalNameValue(annotation);
+    final String? value = _getExternalNameValue(annotation);
     if (value != null) {
       uris.add(value);
     }
@@ -42,7 +40,7 @@
   return uris;
 }
 
-String _getExternalNameValue(Expression annotation) {
+String? _getExternalNameValue(Expression annotation) {
   if (annotation is ConstructorInvocation) {
     if (_isExternalName(annotation.target.enclosingClass)) {
       return (annotation.arguments.positional.single as StringLiteral).value;
diff --git a/pkg/kernel/lib/naive_type_checker.dart b/pkg/kernel/lib/naive_type_checker.dart
index 2a16ee8..d3a6638 100644
--- a/pkg/kernel/lib/naive_type_checker.dart
+++ b/pkg/kernel/lib/naive_type_checker.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'class_hierarchy.dart';
 import 'core_types.dart';
 import 'kernel.dart';
@@ -79,7 +77,7 @@
         final DartType superType = setterType(host, superMember);
         final bool isCovariant = ownMember is Field
             ? ownMember.isCovariant
-            : ownMember.function.positionalParameters[0].isCovariant;
+            : ownMember.function!.positionalParameters[0].isCovariant;
         if (!_isValidParameterOverride(isCovariant, ownType, superType)) {
           if (isCovariant) {
             return failures.reportInvalidOverride(ownMember, superMember, '''
@@ -101,7 +99,8 @@
         }
       }
     } else {
-      final String msg = _checkFunctionOverride(host, ownMember, superMember);
+      final String? msg =
+          _checkFunctionOverride(host, ownMember, superMember as Procedure);
       if (msg != null) {
         return failures.reportInvalidOverride(ownMember, superMember, msg);
       }
@@ -128,7 +127,7 @@
 
   Substitution _makeSubstitutionForMember(Class host, Member member) {
     final Supertype hostType =
-        hierarchy.getClassAsInstanceOf(host, member.enclosingClass);
+        hierarchy.getClassAsInstanceOf(host, member.enclosingClass!)!;
     return Substitution.fromSupertype(hostType);
   }
 
@@ -137,11 +136,10 @@
   ///
   /// Note: this function is a copy of [SubtypeTester._isFunctionSubtypeOf]
   /// but it additionally accounts for parameter covariance.
-  String _checkFunctionOverride(
-      Class host, Member ownMember, Member superMember) {
-    if (ownMember is Procedure &&
-        (ownMember.isMemberSignature ||
-            (ownMember.isForwardingStub && !ownMember.isForwardingSemiStub))) {
+  String? _checkFunctionOverride(
+      Class host, Procedure ownMember, Procedure superMember) {
+    if (ownMember.isMemberSignature ||
+        (ownMember.isForwardingStub && !ownMember.isForwardingSemiStub)) {
       // Synthesized members are not obligated to override super members.
       return null;
     }
@@ -222,7 +220,7 @@
             ownFunction.namedParameters,
             key: (v) => v.name);
     for (VariableDeclaration superParameter in superFunction.namedParameters) {
-      final VariableDeclaration ownParameter =
+      final VariableDeclaration? ownParameter =
           ownParameters[superParameter.name];
       if (ownParameter == null) {
         return 'override is missing ${superParameter.name} parameter';
diff --git a/pkg/kernel/lib/src/const_canonical_type.dart b/pkg/kernel/lib/src/const_canonical_type.dart
index 8e0567e..b7edbd5 100644
--- a/pkg/kernel/lib/src/const_canonical_type.dart
+++ b/pkg/kernel/lib/src/const_canonical_type.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.md file.
 
-// @dart = 2.9
-
 import 'package:kernel/src/bounds_checks.dart';
 
 import '../ast.dart';
@@ -15,7 +13,8 @@
 /// The algorithm is specified at
 /// https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/feature-specification.md#constant-instances
 DartType computeConstCanonicalType(DartType type, CoreTypes coreTypes,
-    {bool isNonNullableByDefault}) {
+    {required bool isNonNullableByDefault}) {
+  // ignore: unnecessary_null_comparison
   assert(isNonNullableByDefault != null);
 
   if (type is InvalidType) {
@@ -112,7 +111,7 @@
     assert(type.declaredNullability == Nullability.nonNullable);
 
     List<TypeParameter> canonicalizedTypeParameters;
-    Substitution substitution;
+    Substitution? substitution;
     if (type.typeParameters.isEmpty) {
       canonicalizedTypeParameters = const <TypeParameter>[];
       substitution = null;
@@ -178,24 +177,24 @@
     }
 
     // Canonicalize typedef type, just in case.
-    TypedefType canonicalizedTypedefType;
-    if (type.typedefType == null) {
+    TypedefType? canonicalizedTypedefType;
+    TypedefType? typedefType = type.typedefType;
+    if (typedefType == null) {
       canonicalizedTypedefType = null;
     } else {
       List<DartType> canonicalizedTypeArguments;
-      if (type.typedefType.typeArguments.isEmpty) {
+      if (typedefType.typeArguments.isEmpty) {
         canonicalizedTypeArguments = const <DartType>[];
       } else {
-        canonicalizedTypeArguments = new List<DartType>.of(
-            type.typedefType.typeArguments,
-            growable: false);
+        canonicalizedTypeArguments =
+            new List<DartType>.of(typedefType.typeArguments, growable: false);
         for (int i = 0; i < canonicalizedTypeArguments.length; ++i) {
           canonicalizedTypeArguments[i] = computeConstCanonicalType(
               canonicalizedTypeArguments[i], coreTypes,
               isNonNullableByDefault: isNonNullableByDefault);
         }
       }
-      canonicalizedTypedefType = new TypedefType(type.typedefType.typedefNode,
+      canonicalizedTypedefType = new TypedefType(typedefType.typedefNode,
           Nullability.legacy, canonicalizedTypeArguments);
     }
 
diff --git a/pkg/kernel/lib/src/dart_type_equivalence.dart b/pkg/kernel/lib/src/dart_type_equivalence.dart
index 08c2009..f720348 100644
--- a/pkg/kernel/lib/src/dart_type_equivalence.dart
+++ b/pkg/kernel/lib/src/dart_type_equivalence.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.md file.
 
-// @dart = 2.9
-
 import '../ast.dart';
 import '../core_types.dart';
 import '../visitor.dart';
@@ -64,7 +62,7 @@
         // themselves if the typedef types are equal.
         assert(() {
           DartTypeEquivalence copy = this.copy();
-          if (!copy.areEqual(node.typedefType, other.typedefType)) {
+          if (!copy.areEqual(node.typedefType!, other.typedefType!)) {
             return true;
           }
           FunctionType nodeWithoutTypedefType = new FunctionType(
@@ -85,7 +83,7 @@
               typedefType: null);
           return copy.areEqual(nodeWithoutTypedefType, otherWithoutTypedefType);
         }());
-        return node.typedefType.accept1(this, other.typedefType);
+        return node.typedefType!.accept1(this, other.typedefType);
       }
 
       // Perform simple number checks before the checks on parts.
@@ -130,7 +128,7 @@
         String otherName = other.namedParameters[i].name;
         DartType otherType = other.namedParameters[i].type;
         if (!nodeNamedParameters.containsKey(otherName) ||
-            !nodeNamedParameters[otherName].accept1(this, otherType)) {
+            !nodeNamedParameters[otherName]!.accept1(this, otherType)) {
           result = false;
         }
       }
@@ -251,7 +249,7 @@
         return false;
       }
       return nodeIsIntersection
-          ? node.promotedBound.accept1(this, other.promotedBound)
+          ? node.promotedBound!.accept1(this, other.promotedBound)
           : true;
     }
     return false;
@@ -315,7 +313,7 @@
   TypeParameter _lookup(TypeParameter parameter) {
     for (int i = _alphaRenamingStack.length - 1; i >= 0; --i) {
       if (_alphaRenamingStack[i].containsKey(parameter)) {
-        return _alphaRenamingStack[i][parameter];
+        return _alphaRenamingStack[i][parameter]!;
       }
     }
     return parameter;
diff --git a/pkg/kernel/lib/src/tool/batch_util.dart b/pkg/kernel/lib/src/tool/batch_util.dart
index 6909087..08d28d9 100644
--- a/pkg/kernel/lib/src/tool/batch_util.dart
+++ b/pkg/kernel/lib/src/tool/batch_util.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 library kernel.batch_util;
 
 import 'dart:convert';
diff --git a/pkg/kernel/lib/src/tool/command_line_util.dart b/pkg/kernel/lib/src/tool/command_line_util.dart
index f0e3f56..df51e1d 100644
--- a/pkg/kernel/lib/src/tool/command_line_util.dart
+++ b/pkg/kernel/lib/src/tool/command_line_util.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:kernel/kernel.dart';
diff --git a/pkg/kernel/lib/src/tool/find_referenced_libraries.dart b/pkg/kernel/lib/src/tool/find_referenced_libraries.dart
index 9988f13..d9bae18 100644
--- a/pkg/kernel/lib/src/tool/find_referenced_libraries.dart
+++ b/pkg/kernel/lib/src/tool/find_referenced_libraries.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:kernel/ast.dart';
 import 'package:kernel/visitor.dart';
 
@@ -32,7 +30,7 @@
       seen(node);
     } else if (node is Name) {
       if (node.library != null) {
-        seen(node.library);
+        seen(node.library!);
       }
     }
     super.defaultNode(node);
@@ -44,10 +42,10 @@
   }
 
   void seen(TreeNode node) {
-    TreeNode parent = node;
+    TreeNode? parent = node;
     while (parent != null && parent is! Library) {
       parent = parent.parent;
     }
-    allSeenLibraries.add(parent);
+    allSeenLibraries.add(parent as Library);
   }
 }
diff --git a/pkg/kernel/lib/testing/mock_sdk.dart b/pkg/kernel/lib/testing/mock_sdk.dart
index 45a7d0c..d4a937b 100644
--- a/pkg/kernel/lib/testing/mock_sdk.dart
+++ b/pkg/kernel/lib/testing/mock_sdk.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 const String mockSdk = """
 class Object;
 class Comparable<T>;
diff --git a/pkg/kernel/lib/testing/mock_sdk_component.dart b/pkg/kernel/lib/testing/mock_sdk_component.dart
index 4c444e2..9562893 100644
--- a/pkg/kernel/lib/testing/mock_sdk_component.dart
+++ b/pkg/kernel/lib/testing/mock_sdk_component.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:kernel/ast.dart';
 
 /// Returns a [Component] object containing empty definitions of core SDK
@@ -20,9 +18,9 @@
   coreLib.addClass(objectClass);
 
   Class addClass(Library lib, String name,
-      {Supertype supertype,
-      List<TypeParameter> typeParameters,
-      List<Supertype> implementedTypes}) {
+      {Supertype? supertype,
+      List<TypeParameter>? typeParameters,
+      List<Supertype>? implementedTypes}) {
     Class c = new Class(
         name: name,
         supertype: supertype ?? objectClass.asThisSupertype,
@@ -36,7 +34,7 @@
   InterfaceType objectType =
       new InterfaceType(objectClass, coreLib.nonNullable);
 
-  TypeParameter typeParam(String name, [DartType bound]) {
+  TypeParameter typeParam(String name, [DartType? bound]) {
     return new TypeParameter(name, bound ?? objectType);
   }
 
diff --git a/pkg/kernel/lib/testing/type_parser.dart b/pkg/kernel/lib/testing/type_parser.dart
index 45ffeab..f2522d3 100644
--- a/pkg/kernel/lib/testing/type_parser.dart
+++ b/pkg/kernel/lib/testing/type_parser.dart
@@ -2,12 +2,10 @@
 // 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
-
 import 'package:kernel/ast.dart' show Nullability;
 
 abstract class ParsedType {
-  R accept<R, A>(Visitor<R, A> visitor, [A a]);
+  R accept<R, A>(Visitor<R, A> visitor, A a);
 }
 
 enum ParsedNullability {
@@ -31,8 +29,6 @@
     case ParsedNullability.omitted:
       return ifOmitted;
   }
-  return throw new UnsupportedError(
-      "$parsedNullability in interpretParsedNullability");
 }
 
 String parsedNullabilityToString(ParsedNullability parsedNullability) {
@@ -44,8 +40,6 @@
     case ParsedNullability.omitted:
       return '';
   }
-  return throw new UnsupportedError(
-      "$parsedNullability parsedNullabilityToString");
 }
 
 class ParsedInterfaceType extends ParsedType {
@@ -69,7 +63,7 @@
     return "$sb";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitInterfaceType(this, a);
   }
 }
@@ -82,10 +76,10 @@
 
 class ParsedClass extends ParsedDeclaration {
   final List<ParsedTypeVariable> typeVariables;
-  final ParsedInterfaceType supertype;
-  final ParsedInterfaceType mixedInType;
+  final ParsedInterfaceType? supertype;
+  final ParsedInterfaceType? mixedInType;
   final List<ParsedType> interfaces;
-  final ParsedFunctionType callableType;
+  final ParsedFunctionType? callableType;
 
   ParsedClass(String name, this.typeVariables, this.supertype, this.mixedInType,
       this.interfaces, this.callableType)
@@ -118,7 +112,7 @@
     return "$sb";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitClass(this, a);
   }
 }
@@ -144,7 +138,7 @@
     return "$sb";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitExtension(this, a);
   }
 }
@@ -170,7 +164,7 @@
     return "$sb;";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitTypedef(this, a);
   }
 }
@@ -202,7 +196,7 @@
     return "$sb";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitFunctionType(this, a);
   }
 }
@@ -210,7 +204,7 @@
 class ParsedVoidType extends ParsedType {
   String toString() => "void";
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitVoidType(this, a);
   }
 }
@@ -218,7 +212,7 @@
 class ParsedTypeVariable extends ParsedType {
   final String name;
 
-  final ParsedType bound;
+  final ParsedType? bound;
 
   ParsedTypeVariable(this.name, this.bound);
 
@@ -231,7 +225,7 @@
     return "$sb";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitTypeVariable(this, a);
   }
 }
@@ -251,7 +245,7 @@
     return "$sb";
   }
 
-  R accept<R, A>(Visitor<R, A> visitor, [A a]) {
+  R accept<R, A>(Visitor<R, A> visitor, A a) {
     return visitor.visitIntersectionType(this, a);
   }
 }
@@ -311,10 +305,10 @@
 
 class Token {
   final int charOffset;
-  final String text;
+  final String? text;
   final bool isIdentifier;
 
-  Token next;
+  Token? next;
 
   Token(this.charOffset, this.text, {this.isIdentifier: false});
 
@@ -331,7 +325,7 @@
   bool get atEof => peek.isEof;
 
   void advance() {
-    peek = peek.next;
+    peek = peek.next!;
   }
 
   String computeLocation() {
@@ -404,7 +398,7 @@
       results.add(type);
     } while (optionalAdvance("&"));
     // Parse `A & B & C` as `A & (B & C)` and not `(A & B) & C`.
-    ParsedType result;
+    ParsedType? result;
     for (ParsedType type in results.reversed) {
       if (result == null) {
         result = type;
@@ -412,7 +406,7 @@
         result = new ParsedIntersectionType(type, result);
       }
     }
-    return result;
+    return result!;
   }
 
   ParsedType parseReturnType() {
@@ -436,7 +430,7 @@
       throw "Expected a name, "
           "but got '${peek.text}'\n${computeLocation()}";
     }
-    String result = peek.text;
+    String result = peek.text!;
     advance();
     return result;
   }
@@ -485,7 +479,7 @@
 
   ParsedTypeVariable parseTypeVariable() {
     String name = parseName();
-    ParsedType bound;
+    ParsedType? bound;
     if (optionalAdvance("extends")) {
       bound = parseType();
     }
@@ -496,12 +490,12 @@
     expect("class");
     String name = parseName();
     List<ParsedTypeVariable> typeVariables = parseTypeVariablesOpt();
-    ParsedType supertype;
-    ParsedType mixedInType;
+    ParsedInterfaceType? supertype;
+    ParsedInterfaceType? mixedInType;
     if (optionalAdvance("extends")) {
-      supertype = parseType();
+      supertype = parseType() as ParsedInterfaceType;
       if (optionalAdvance("with")) {
-        mixedInType = parseType();
+        mixedInType = parseType() as ParsedInterfaceType;
       }
     }
     List<ParsedType> interfaces = <ParsedType>[];
@@ -510,7 +504,7 @@
         interfaces.add(parseType());
       } while (optionalAdvance(","));
     }
-    ParsedFunctionType callableType;
+    ParsedFunctionType? callableType;
     if (optionalAdvance("{")) {
       callableType = parseFunctionType();
       expect("}");
@@ -526,7 +520,7 @@
     String name = parseName();
     List<ParsedTypeVariable> typeVariables = parseTypeVariablesOpt();
     expect("on");
-    ParsedType onType = parseType();
+    ParsedInterfaceType onType = parseType() as ParsedInterfaceType;
     expect(";");
     return new ParsedExtension(name, typeVariables, onType);
   }
@@ -585,8 +579,8 @@
 
 Token scanString(String text) {
   int offset = 0;
-  Token first;
-  Token current;
+  Token? first;
+  Token? current;
   while (offset < text.length) {
     int c = text.codeUnitAt(offset);
     if (isWhiteSpace(c)) {
@@ -621,7 +615,7 @@
   } else {
     current.next = eof;
   }
-  return first;
+  return first!;
 }
 
 List<ParsedType> parse(String text) {
@@ -635,7 +629,7 @@
 
 List<ParsedTypeVariable> parseTypeVariables(String text) {
   Parser parser = new Parser(scanString(text), text);
-  List<ParsedType> result = parser.parseTypeVariablesOpt();
+  List<ParsedTypeVariable> result = parser.parseTypeVariablesOpt();
   if (!parser.atEof) {
     throw "Expected EOF, but got '${parser.peek.text}'\n"
         "${parser.computeLocation()}";
diff --git a/pkg/kernel/lib/testing/type_parser_environment.dart b/pkg/kernel/lib/testing/type_parser_environment.dart
index 8b1cbe0..3457810 100644
--- a/pkg/kernel/lib/testing/type_parser_environment.dart
+++ b/pkg/kernel/lib/testing/type_parser_environment.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import "package:kernel/ast.dart" hide Visitor;
 
 import 'package:kernel/core_types.dart' show CoreTypes;
@@ -41,7 +39,7 @@
 }
 
 Library parseLibrary(Uri uri, String text,
-    {Uri fileUri, TypeParserEnvironment environment}) {
+    {Uri? fileUri, TypeParserEnvironment? environment}) {
   fileUri ??= uri;
   environment ??= new TypeParserEnvironment(uri, fileUri);
   Library library =
@@ -53,15 +51,17 @@
       environment._registerDeclaration(
           name,
           new Class(fileUri: fileUri, name: name)
-            ..typeParameters.addAll(new List<TypeParameter>.filled(
-                type.typeVariables.length, null)));
+            ..typeParameters.addAll(new List<TypeParameter>.generate(
+                type.typeVariables.length,
+                (int i) => new TypeParameter('T$i'))));
     } else if (type is ParsedExtension) {
       String name = type.name;
       environment._registerDeclaration(
           name,
           new Extension(fileUri: fileUri, name: name)
-            ..typeParameters.addAll(new List<TypeParameter>.filled(
-                type.typeVariables.length, null)));
+            ..typeParameters.addAll(new List<TypeParameter>.generate(
+                type.typeVariables.length,
+                (int i) => new TypeParameter('T$i'))));
     }
   }
   for (ParsedType type in types) {
@@ -80,15 +80,16 @@
 }
 
 class Env {
-  Component component;
+  late Component component;
 
-  CoreTypes coreTypes;
+  late CoreTypes coreTypes;
 
-  TypeParserEnvironment _libraryEnvironment;
+  late TypeParserEnvironment _libraryEnvironment;
 
   final bool isNonNullableByDefault;
 
-  Env(String source, {this.isNonNullableByDefault}) {
+  Env(String source, {required this.isNonNullableByDefault}) {
+    // ignore: unnecessary_null_comparison
     assert(isNonNullableByDefault != null);
     Uri libraryUri = Uri.parse('memory:main.dart');
     Uri coreUri = Uri.parse("dart:core");
@@ -108,18 +109,18 @@
   }
 
   DartType parseType(String text,
-      {Map<String, DartType Function()> additionalTypes}) {
+      {Map<String, DartType Function()>? additionalTypes}) {
     return _libraryEnvironment.parseType(text,
         additionalTypes: additionalTypes);
   }
 
   List<DartType> parseTypes(String text,
-      {Map<String, DartType Function()> additionalTypes}) {
+      {Map<String, DartType Function()>? additionalTypes}) {
     return _libraryEnvironment.parseTypes(text,
         additionalTypes: additionalTypes);
   }
 
-  List<TypeParameter> extendWithTypeParameters(String typeParameters) {
+  List<TypeParameter> extendWithTypeParameters(String? typeParameters) {
     if (typeParameters == null || typeParameters.isEmpty) {
       return <TypeParameter>[];
     }
@@ -130,7 +131,7 @@
   }
 
   void withTypeParameters(
-      String typeParameters, void Function(List<TypeParameter>) f) {
+      String? typeParameters, void Function(List<TypeParameter>) f) {
     if (typeParameters == null || typeParameters.isEmpty) {
       f(<TypeParameter>[]);
     } else {
@@ -150,7 +151,7 @@
 
   final Map<String, TreeNode> _declarations = <String, TreeNode>{};
 
-  final TypeParserEnvironment _parent;
+  final TypeParserEnvironment? _parent;
 
   /// Collects types to set their nullabilities after type parameters are ready.
   ///
@@ -167,7 +168,7 @@
   TypeParserEnvironment(this.uri, this.fileUri, [this._parent]);
 
   Node _kernelFromParsedType(ParsedType type,
-      {Map<String, DartType Function()> additionalTypes}) {
+      {Map<String, DartType Function()>? additionalTypes}) {
     Node node = type.accept(
         new _KernelFromParsedType(additionalTypes: additionalTypes), this);
     return node;
@@ -175,14 +176,14 @@
 
   /// Parses a single type.
   DartType parseType(String text,
-      {Map<String, DartType Function()> additionalTypes}) {
+      {Map<String, DartType Function()>? additionalTypes}) {
     return _kernelFromParsedType(type_parser.parse(text).single,
-        additionalTypes: additionalTypes);
+        additionalTypes: additionalTypes) as DartType;
   }
 
   /// Parses a list of types separated by commas.
   List<DartType> parseTypes(String text,
-      {Map<String, DartType Function()> additionalTypes}) {
+      {Map<String, DartType Function()>? additionalTypes}) {
     return (parseType("(${text}) -> void", additionalTypes: additionalTypes)
             as FunctionType)
         .positionalParameters;
@@ -190,19 +191,19 @@
 
   bool isObject(String name) => name == "Object" && "$uri" == "dart:core";
 
-  Class get objectClass => lookupDeclaration("Object");
+  Class get objectClass => lookupDeclaration("Object") as Class;
 
   TreeNode lookupDeclaration(String name) {
-    TreeNode result = _declarations[name];
+    TreeNode? result = _declarations[name];
     if (result == null && _parent != null) {
-      return _parent.lookupDeclaration(name);
+      return _parent!.lookupDeclaration(name);
     }
     if (result == null) throw "Not found: $name";
     return result;
   }
 
-  TreeNode _registerDeclaration(String name, TreeNode declaration) {
-    TreeNode existing = _declarations[name];
+  T _registerDeclaration<T extends TreeNode>(String name, T declaration) {
+    TreeNode? existing = _declarations[name];
     if (existing != null) {
       throw "Duplicated declaration: $name";
     }
@@ -214,12 +215,13 @@
       .._declarations.addAll(declarations);
   }
 
-  TypeParserEnvironment extendWithTypeParameters(String typeParameters) {
+  TypeParserEnvironment extendWithTypeParameters(String? typeParameters) {
     if (typeParameters?.isEmpty ?? true) return this;
-    return extendToParameterEnvironment(typeParameters).environment;
+    return extendToParameterEnvironment(typeParameters!).environment;
   }
 
   ParameterEnvironment extendToParameterEnvironment(String typeParameters) {
+    // ignore: unnecessary_null_comparison
     assert(typeParameters != null && typeParameters.isNotEmpty);
     return const _KernelFromParsedType().computeTypeParameterEnvironment(
         parseTypeVariables("<${typeParameters}>"), this);
@@ -228,23 +230,34 @@
   /// Returns the predefined type by the [name], if any.
   ///
   /// Use this in subclasses to add support for additional predefined types.
-  DartType getPredefinedNamedType(String name) {
+  DartType? getPredefinedNamedType(String name) {
     if (_parent != null) {
-      return _parent.getPredefinedNamedType(name);
+      return _parent!.getPredefinedNamedType(name);
     }
     return null;
   }
 }
 
 class _KernelFromParsedType implements Visitor<Node, TypeParserEnvironment> {
-  final Map<String, DartType Function()> additionalTypes; // Can be null.
+  final Map<String, DartType Function()>? additionalTypes; // Can be null.
 
   const _KernelFromParsedType({this.additionalTypes});
 
+  DartType _parseType(ParsedType type, TypeParserEnvironment environment) {
+    return type.accept<Node, TypeParserEnvironment>(this, environment)
+        as DartType;
+  }
+
+  InterfaceType? _parseOptionalInterfaceType(
+      ParsedType? type, TypeParserEnvironment environment) {
+    return type?.accept<Node, TypeParserEnvironment>(this, environment)
+        as InterfaceType?;
+  }
+
   DartType visitInterfaceType(
       ParsedInterfaceType node, TypeParserEnvironment environment) {
     String name = node.name;
-    DartType predefined = environment.getPredefinedNamedType(name);
+    DartType? predefined = environment.getPredefinedNamedType(name);
     if (predefined != null) {
       return predefined;
     } else if (name == "dynamic") {
@@ -268,16 +281,15 @@
       // Don't return a const object to ensure we test implementations that use
       // identical.
       return new InvalidType();
-    } else if (additionalTypes != null && additionalTypes.containsKey(name)) {
-      return additionalTypes[name].call();
+    } else if (additionalTypes != null && additionalTypes!.containsKey(name)) {
+      return additionalTypes![name]!.call();
     }
     TreeNode declaration = environment.lookupDeclaration(name);
     List<ParsedType> arguments = node.arguments;
     List<DartType> kernelArguments =
-        new List<DartType>.filled(arguments.length, null);
+        new List<DartType>.filled(arguments.length, dummyDartType);
     for (int i = 0; i < arguments.length; i++) {
-      kernelArguments[i] =
-          arguments[i].accept<Node, TypeParserEnvironment>(this, environment);
+      kernelArguments[i] = _parseType(arguments[i], environment);
     }
     if (name == "FutureOr") {
       return new FutureOrType(kernelArguments.single,
@@ -296,7 +308,8 @@
       }
       List<TypeParameter> typeVariables = declaration.typeParameters;
       if (kernelArguments.isEmpty && typeVariables.isNotEmpty) {
-        kernelArguments = new List<DartType>.filled(typeVariables.length, null);
+        kernelArguments =
+            new List<DartType>.filled(typeVariables.length, dummyDartType);
         for (int i = 0; i < typeVariables.length; i++) {
           kernelArguments[i] = typeVariables[i].defaultType;
         }
@@ -310,7 +323,7 @@
       }
       Nullability nullability =
           identical(declaration.bound, TypeParameter.unsetBoundSentinel)
-              ? null
+              ? Nullability.nonNullable
               : TypeParameterType.computeNullabilityFromBound(declaration);
       TypeParameterType type = new TypeParameterType(
           declaration,
@@ -320,6 +333,7 @@
       // the bound because it's not yet available, it will be set to null.  In
       // that case, put it to the list to be updated later, when the bound is
       // available.
+      // ignore: unnecessary_null_comparison
       if (type.declaredNullability == null) {
         environment.pendingNullabilities.add(type);
       }
@@ -337,7 +351,7 @@
 
   Class visitClass(ParsedClass node, TypeParserEnvironment environment) {
     String name = node.name;
-    Class cls = environment.lookupDeclaration(name);
+    Class cls = environment.lookupDeclaration(name) as Class;
     ParameterEnvironment parameterEnvironment =
         computeTypeParameterEnvironment(node.typeVariables, environment);
     List<TypeParameter> parameters = parameterEnvironment.parameters;
@@ -347,8 +361,8 @@
       ..addAll(parameters);
     {
       TypeParserEnvironment environment = parameterEnvironment.environment;
-      InterfaceType type = node.supertype
-          ?.accept<Node, TypeParserEnvironment>(this, environment);
+      InterfaceType? type =
+          _parseOptionalInterfaceType(node.supertype, environment);
       if (type == null) {
         if (!environment.isObject(name)) {
           cls.supertype = environment.objectClass.asRawSupertype;
@@ -356,15 +370,15 @@
       } else {
         cls.supertype = toSupertype(type);
       }
-      InterfaceType mixedInType = node.mixedInType
-          ?.accept<Node, TypeParserEnvironment>(this, environment);
+      InterfaceType? mixedInType =
+          _parseOptionalInterfaceType(node.mixedInType, environment);
       if (mixedInType != null) {
         cls.mixedInType = toSupertype(mixedInType);
       }
       List<ParsedType> interfaces = node.interfaces;
       for (int i = 0; i < interfaces.length; i++) {
-        cls.implementedTypes.add(toSupertype(interfaces[i]
-            .accept<Node, TypeParserEnvironment>(this, environment)));
+        cls.implementedTypes.add(toSupertype(
+            _parseOptionalInterfaceType(interfaces[i], environment)!));
       }
     }
     return cls;
@@ -373,7 +387,7 @@
   Extension visitExtension(
       ParsedExtension node, TypeParserEnvironment environment) {
     String name = node.name;
-    Extension ext = environment.lookupDeclaration(name);
+    Extension ext = environment.lookupDeclaration(name) as Extension;
     ParameterEnvironment parameterEnvironment =
         computeTypeParameterEnvironment(node.typeVariables, environment);
     List<TypeParameter> parameters = parameterEnvironment.parameters;
@@ -383,8 +397,8 @@
       ..addAll(parameters);
     {
       TypeParserEnvironment environment = parameterEnvironment.environment;
-      DartType onType =
-          node.onType?.accept<Node, TypeParserEnvironment>(this, environment);
+      DartType onType = node.onType
+          .accept<Node, TypeParserEnvironment>(this, environment) as DartType;
       ext.onType = onType;
     }
     return ext;
@@ -400,7 +414,7 @@
     DartType type;
     {
       TypeParserEnvironment environment = parameterEnvironment.environment;
-      type = node.type.accept<Node, TypeParserEnvironment>(this, environment);
+      type = _parseType(node.type, environment);
       if (type is FunctionType) {
         FunctionType f = type;
         type = new FunctionType(
@@ -429,21 +443,16 @@
     DartType returnType;
     {
       TypeParserEnvironment environment = parameterEnvironment.environment;
-      returnType = node.returnType
-          ?.accept<Node, TypeParserEnvironment>(this, environment);
+      returnType = _parseType(node.returnType, environment);
       for (ParsedType argument in node.arguments.required) {
-        positionalParameters.add(
-            argument.accept<Node, TypeParserEnvironment>(this, environment));
+        positionalParameters.add(_parseType(argument, environment));
       }
       for (ParsedType argument in node.arguments.positional) {
-        positionalParameters.add(
-            argument.accept<Node, TypeParserEnvironment>(this, environment));
+        positionalParameters.add(_parseType(argument, environment));
       }
       for (ParsedNamedArgument argument in node.arguments.named) {
         namedParameters.add(new NamedType(
-            argument.name,
-            argument.type
-                .accept<Node, TypeParserEnvironment>(this, environment),
+            argument.name, _parseType(argument.type, environment),
             isRequired: argument.isRequired));
       }
     }
@@ -468,9 +477,8 @@
   TypeParameterType visitIntersectionType(
       ParsedIntersectionType node, TypeParserEnvironment environment) {
     TypeParameterType type =
-        node.a.accept<Node, TypeParserEnvironment>(this, environment);
-    DartType bound =
-        node.b.accept<Node, TypeParserEnvironment>(this, environment);
+        _parseType(node.a, environment) as TypeParameterType;
+    DartType bound = _parseType(node.b, environment);
     return new TypeParameterType.intersection(
         type.parameter, type.nullability, bound);
   }
@@ -482,8 +490,8 @@
   ParameterEnvironment computeTypeParameterEnvironment(
       List<ParsedTypeVariable> typeVariables,
       TypeParserEnvironment environment) {
-    List<TypeParameter> typeParameters =
-        new List<TypeParameter>.filled(typeVariables.length, null);
+    List<TypeParameter> typeParameters = new List<TypeParameter>.filled(
+        typeVariables.length, dummyTypeParameter);
     Map<String, TypeParameter> typeParametersByName = <String, TypeParameter>{};
     for (int i = 0; i < typeVariables.length; i++) {
       String name = typeVariables[i].name;
@@ -493,7 +501,7 @@
         environment._extend(typeParametersByName);
     Class objectClass = environment.objectClass;
     for (int i = 0; i < typeVariables.length; i++) {
-      ParsedType bound = typeVariables[i].bound;
+      ParsedType? bound = typeVariables[i].bound;
       TypeParameter typeParameter = typeParameters[i];
       if (bound == null) {
         typeParameter
@@ -501,8 +509,7 @@
               objectClass, Nullability.nullable, const <DartType>[])
           ..defaultType = const DynamicType();
       } else {
-        DartType type =
-            bound.accept<Node, TypeParserEnvironment>(this, nestedEnvironment);
+        DartType type = _parseType(bound, nestedEnvironment);
         typeParameter
           ..bound = type
           // The default type will be overridden below, but we need to set it
diff --git a/pkg/kernel/lib/transformations/empty.dart b/pkg/kernel/lib/transformations/empty.dart
index c07883b..5a264dd7 100644
--- a/pkg/kernel/lib/transformations/empty.dart
+++ b/pkg/kernel/lib/transformations/empty.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 library kernel.transformations.empty;
 
 import '../ast.dart';
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index e8fa6a3..18478d0 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 library kernel.type_checker;
 
 import 'ast.dart';
@@ -20,9 +18,9 @@
   final CoreTypes coreTypes;
   final ClassHierarchy hierarchy;
   final bool ignoreSdk;
-  TypeEnvironment environment;
-  Library currentLibrary;
-  InterfaceType currentThisType;
+  final TypeEnvironment environment;
+  Library? currentLibrary;
+  InterfaceType? currentThisType;
 
   TypeChecker(this.coreTypes, this.hierarchy, {this.ignoreSdk: true})
       : environment = new TypeEnvironment(coreTypes, hierarchy);
@@ -68,14 +66,14 @@
 
   DartType getterType(Class host, Member member) {
     Supertype hostType =
-        hierarchy.getClassAsInstanceOf(host, member.enclosingClass);
+        hierarchy.getClassAsInstanceOf(host, member.enclosingClass!)!;
     Substitution substitution = Substitution.fromSupertype(hostType);
     return substitution.substituteType(member.getterType);
   }
 
   DartType setterType(Class host, Member member) {
     Supertype hostType =
-        hierarchy.getClassAsInstanceOf(host, member.enclosingClass);
+        hierarchy.getClassAsInstanceOf(host, member.enclosingClass!)!;
     Substitution substitution = Substitution.fromSupertype(hostType);
     return substitution.substituteType(member.setterType, contravariant: true);
   }
@@ -128,12 +126,12 @@
   final ClassHierarchy hierarchy;
 
   CoreTypes get coreTypes => environment.coreTypes;
-  Library get currentLibrary => checker.currentLibrary;
-  Class get currentClass => checker.currentThisType.classNode;
-  InterfaceType get currentThisType => checker.currentThisType;
+  Library? get currentLibrary => checker.currentLibrary;
+  Class? get currentClass => checker.currentThisType?.classNode;
+  InterfaceType? get currentThisType => checker.currentThisType;
 
-  DartType currentReturnType;
-  DartType currentYieldType;
+  DartType? currentReturnType;
+  DartType? currentYieldType;
   AsyncMarker currentAsyncMarker = AsyncMarker.Sync;
 
   TypeCheckingVisitor(this.checker, this.environment, this.hierarchy);
@@ -147,7 +145,7 @@
   }
 
   Expression checkAndDowncastExpression(Expression from, DartType to) {
-    TreeNode parent = from.parent;
+    TreeNode? parent = from.parent;
     DartType type = visitExpression(from);
     Expression result = checker.checkAndDowncastExpression(from, type, to);
     result.parent = parent;
@@ -193,7 +191,7 @@
   visitField(Field node) {
     if (node.initializer != null) {
       node.initializer =
-          checkAndDowncastExpression(node.initializer, node.type);
+          checkAndDowncastExpression(node.initializer!, node.type);
     }
   }
 
@@ -223,14 +221,14 @@
         .forEach(handleOptionalParameter);
     node.namedParameters.forEach(handleOptionalParameter);
     if (node.body != null) {
-      visitStatement(node.body);
+      visitStatement(node.body!);
     }
     currentAsyncMarker = oldAsyncMarker;
   }
 
   void handleNestedFunctionNode(FunctionNode node) {
-    DartType oldReturn = currentReturnType;
-    DartType oldYield = currentYieldType;
+    DartType? oldReturn = currentReturnType;
+    DartType? oldYield = currentYieldType;
     currentReturnType = _getInternalReturnType(node);
     currentYieldType = _getYieldType(node);
     handleFunctionNode(node);
@@ -241,19 +239,19 @@
   void handleOptionalParameter(VariableDeclaration parameter) {
     if (parameter.initializer != null) {
       // Default parameter values cannot be downcast.
-      checkExpressionNoDowncast(parameter.initializer, parameter.type);
+      checkExpressionNoDowncast(parameter.initializer!, parameter.type);
     }
   }
 
   Substitution getReceiverType(
       TreeNode access, Expression receiver, Member member) {
     DartType type = visitExpression(receiver);
-    Class superclass = member.enclosingClass;
+    Class superclass = member.enclosingClass!;
     if (superclass.supertype == null) {
       return Substitution.empty; // Members on Object are always accessible.
     }
     while (type is TypeParameterType) {
-      type = (type as TypeParameterType).bound;
+      type = type.bound;
     }
     if (type is NeverType || type is NullType) {
       // The bottom type is a subtype of all types, so it should be allowed.
@@ -261,7 +259,7 @@
     }
     if (type is InterfaceType) {
       // The receiver type should implement the interface declaring the member.
-      List<DartType> upcastTypeArguments =
+      List<DartType>? upcastTypeArguments =
           hierarchy.getTypeArgumentsAsInstanceOf(type, superclass);
       if (upcastTypeArguments != null) {
         return Substitution.fromPairs(
@@ -280,27 +278,27 @@
 
   Substitution getSuperReceiverType(Member member) {
     return Substitution.fromSupertype(
-        hierarchy.getClassAsInstanceOf(currentClass, member.enclosingClass));
+        hierarchy.getClassAsInstanceOf(currentClass!, member.enclosingClass!)!);
   }
 
   DartType handleCall(Arguments arguments, DartType functionType,
       {Substitution receiver: Substitution.empty,
-      List<TypeParameter> typeParameters}) {
+      List<TypeParameter>? typeParameters}) {
     if (functionType is FunctionType) {
       typeParameters ??= functionType.typeParameters;
       if (arguments.positional.length < functionType.requiredParameterCount) {
         fail(arguments, 'Too few positional arguments');
-        return NeverType.fromNullability(currentLibrary.nonNullable);
+        return NeverType.fromNullability(currentLibrary!.nonNullable);
       }
       if (arguments.positional.length >
           functionType.positionalParameters.length) {
         fail(arguments, 'Too many positional arguments');
-        return NeverType.fromNullability(currentLibrary.nonNullable);
+        return NeverType.fromNullability(currentLibrary!.nonNullable);
       }
       List<DartType> typeArguments = arguments.types;
       if (typeArguments.length != typeParameters.length) {
         fail(arguments, 'Wrong number of type arguments');
-        return NeverType.fromNullability(currentLibrary.nonNullable);
+        return NeverType.fromNullability(currentLibrary!.nonNullable);
       }
       Substitution substitution = _instantiateFunction(
           typeParameters, typeArguments, arguments,
@@ -328,7 +326,7 @@
         }
         if (!found) {
           fail(argument.value, 'Unexpected named parameter: ${argument.name}');
-          return NeverType.fromNullability(currentLibrary.nonNullable);
+          return NeverType.fromNullability(currentLibrary!.nonNullable);
         }
       }
       return substitution.substituteType(functionType.returnType);
@@ -339,7 +337,7 @@
     }
   }
 
-  DartType _getInternalReturnType(FunctionNode function) {
+  DartType? _getInternalReturnType(FunctionNode function) {
     switch (function.asyncMarker) {
       case AsyncMarker.Sync:
         return function.returnType;
@@ -359,17 +357,17 @@
       case AsyncMarker.SyncYielding:
         // The SyncStar transform wraps the original function body twice,
         // where the inner most function returns bool.
-        TreeNode parent = function.parent;
+        TreeNode? parent = function.parent;
         while (parent is! FunctionNode) {
-          parent = parent.parent;
+          parent = parent!.parent;
         }
-        FunctionNode enclosingFunction = parent as FunctionNode;
+        FunctionNode enclosingFunction = parent;
         if (enclosingFunction.dartAsyncMarker == AsyncMarker.Sync) {
           parent = enclosingFunction.parent;
           while (parent is! FunctionNode) {
-            parent = parent.parent;
+            parent = parent!.parent;
           }
-          enclosingFunction = parent as FunctionNode;
+          enclosingFunction = parent;
           if (enclosingFunction.dartAsyncMarker == AsyncMarker.SyncStar) {
             return coreTypes.boolLegacyRawType;
           }
@@ -381,7 +379,7 @@
     }
   }
 
-  DartType _getYieldType(FunctionNode function) {
+  DartType? _getYieldType(FunctionNode function) {
     switch (function.asyncMarker) {
       case AsyncMarker.Sync:
       case AsyncMarker.Async:
@@ -408,7 +406,7 @@
 
   Substitution _instantiateFunction(List<TypeParameter> typeParameters,
       List<DartType> typeArguments, TreeNode where,
-      {Substitution receiverSubstitution}) {
+      {Substitution? receiverSubstitution}) {
     Substitution instantiation =
         Substitution.fromPairs(typeParameters, typeArguments);
     Substitution substitution = receiverSubstitution == null
@@ -459,7 +457,7 @@
             .computeThisFunctionType(class_.enclosingLibrary.nonNullable),
         typeParameters: class_.typeParameters);
     return new InterfaceType(
-        target.enclosingClass, currentLibrary.nonNullable, arguments.types);
+        target.enclosingClass, currentLibrary!.nonNullable, arguments.types);
   }
 
   @override
@@ -470,7 +468,7 @@
   @override
   DartType visitFunctionExpression(FunctionExpression node) {
     handleNestedFunctionNode(node.function);
-    return node.function.computeThisFunctionType(currentLibrary.nonNullable);
+    return node.function.computeThisFunctionType(currentLibrary!.nonNullable);
   }
 
   @override
@@ -491,7 +489,7 @@
 
   @override
   DartType visitLet(Let node) {
-    DartType value = visitExpression(node.variable.initializer);
+    DartType value = visitExpression(node.variable.initializer!);
     if (node.variable.type is DynamicType) {
       node.variable.type = value;
     }
@@ -509,12 +507,12 @@
     DartType type = visitExpression(node.expression);
     if (type is! FunctionType) {
       fail(node, 'Not a function type: $type');
-      return NeverType.fromNullability(currentLibrary.nonNullable);
+      return NeverType.fromNullability(currentLibrary!.nonNullable);
     }
     FunctionType functionType = type;
     if (functionType.typeParameters.length != node.typeArguments.length) {
       fail(node, 'Wrong number of type arguments');
-      return NeverType.fromNullability(currentLibrary.nonNullable);
+      return NeverType.fromNullability(currentLibrary!.nonNullable);
     }
     return _instantiateFunction(
             functionType.typeParameters, node.typeArguments, node)
@@ -527,7 +525,7 @@
       node.expressions[i] =
           checkAndDowncastExpression(node.expressions[i], node.typeArgument);
     }
-    return environment.listType(node.typeArgument, currentLibrary.nonNullable);
+    return environment.listType(node.typeArgument, currentLibrary!.nonNullable);
   }
 
   @override
@@ -536,7 +534,7 @@
       node.expressions[i] =
           checkAndDowncastExpression(node.expressions[i], node.typeArgument);
     }
-    return environment.setType(node.typeArgument, currentLibrary.nonNullable);
+    return environment.setType(node.typeArgument, currentLibrary!.nonNullable);
   }
 
   @override
@@ -555,7 +553,7 @@
       entry.value = checkAndDowncastExpression(entry.value, node.valueType);
     }
     return environment.mapType(
-        node.keyType, node.valueType, currentLibrary.nonNullable);
+        node.keyType, node.valueType, currentLibrary!.nonNullable);
   }
 
   DartType handleDynamicCall(DartType receiver, Arguments arguments) {
@@ -568,15 +566,15 @@
       TreeNode access, FunctionType function, Arguments arguments) {
     if (function.requiredParameterCount > arguments.positional.length) {
       fail(access, 'Too few positional arguments');
-      return NeverType.fromNullability(currentLibrary.nonNullable);
+      return NeverType.fromNullability(currentLibrary!.nonNullable);
     }
     if (function.positionalParameters.length < arguments.positional.length) {
       fail(access, 'Too many positional arguments');
-      return NeverType.fromNullability(currentLibrary.nonNullable);
+      return NeverType.fromNullability(currentLibrary!.nonNullable);
     }
     if (function.typeParameters.length != arguments.types.length) {
       fail(access, 'Wrong number of type arguments');
-      return NeverType.fromNullability(currentLibrary.nonNullable);
+      return NeverType.fromNullability(currentLibrary!.nonNullable);
     }
     Substitution instantiation =
         Substitution.fromPairs(function.typeParameters, arguments.types);
@@ -589,7 +587,7 @@
     }
     for (int i = 0; i < arguments.named.length; ++i) {
       NamedExpression argument = arguments.named[i];
-      DartType parameterType = function.getNamedParameter(argument.name);
+      DartType? parameterType = function.getNamedParameter(argument.name);
       if (parameterType != null) {
         DartType expectedType =
             instantiation.substituteType(parameterType, contravariant: true);
@@ -597,7 +595,7 @@
             checkAndDowncastExpression(argument.value, expectedType);
       } else {
         fail(argument.value, 'Unexpected named parameter: ${argument.name}');
-        return NeverType.fromNullability(currentLibrary.nonNullable);
+        return NeverType.fromNullability(currentLibrary!.nonNullable);
       }
     }
     return instantiation.substituteType(function.returnType);
@@ -605,7 +603,7 @@
 
   @override
   DartType visitMethodInvocation(MethodInvocation node) {
-    Member target = node.interfaceTarget;
+    Member? target = node.interfaceTarget;
     if (target == null) {
       DartType receiver = visitExpression(node.receiver);
       if (node.name.text == '==') {
@@ -626,34 +624,31 @@
           receiver, argument);
     } else {
       return handleCall(node.arguments, target.getterType,
-          receiver: getReceiverType(node, node.receiver, node.interfaceTarget));
+          receiver: getReceiverType(node, node.receiver, target));
     }
   }
 
   @override
   DartType visitPropertyGet(PropertyGet node) {
-    if (node.interfaceTarget == null) {
+    Member? target = node.interfaceTarget;
+    if (target == null) {
       final DartType receiver = visitExpression(node.receiver);
       checkUnresolvedInvocation(receiver, node);
       return const DynamicType();
     } else {
-      Substitution receiver =
-          getReceiverType(node, node.receiver, node.interfaceTarget);
-      return receiver.substituteType(node.interfaceTarget.getterType);
+      Substitution receiver = getReceiverType(node, node.receiver, target);
+      return receiver.substituteType(target.getterType);
     }
   }
 
   @override
   DartType visitPropertySet(PropertySet node) {
+    Member? target = node.interfaceTarget;
     DartType value = visitExpression(node.value);
-    if (node.interfaceTarget != null) {
-      Substitution receiver =
-          getReceiverType(node, node.receiver, node.interfaceTarget);
-      checkAssignable(
-          node.value,
-          value,
-          receiver.substituteType(node.interfaceTarget.setterType,
-              contravariant: true));
+    if (target != null) {
+      Substitution receiver = getReceiverType(node, node.receiver, target);
+      checkAssignable(node.value, value,
+          receiver.substituteType(target.setterType, contravariant: true));
     } else {
       final DartType receiver = visitExpression(node.receiver);
       checkUnresolvedInvocation(receiver, node);
@@ -680,7 +675,7 @@
 
   @override
   DartType visitRethrow(Rethrow node) {
-    return NeverType.fromNullability(currentLibrary.nonNullable);
+    return NeverType.fromNullability(currentLibrary!.nonNullable);
   }
 
   @override
@@ -708,8 +703,8 @@
 
   @override
   DartType visitListConcatenation(ListConcatenation node) {
-    DartType type =
-        environment.iterableType(node.typeArgument, currentLibrary.nonNullable);
+    DartType type = environment.iterableType(
+        node.typeArgument, currentLibrary!.nonNullable);
     for (Expression part in node.lists) {
       DartType partType = visitExpression(part);
       checkAssignable(node, type, partType);
@@ -719,8 +714,8 @@
 
   @override
   DartType visitSetConcatenation(SetConcatenation node) {
-    DartType type =
-        environment.iterableType(node.typeArgument, currentLibrary.nonNullable);
+    DartType type = environment.iterableType(
+        node.typeArgument, currentLibrary!.nonNullable);
     for (Expression part in node.sets) {
       DartType partType = visitExpression(part);
       checkAssignable(node, type, partType);
@@ -731,7 +726,7 @@
   @override
   DartType visitMapConcatenation(MapConcatenation node) {
     DartType type = environment.mapType(
-        node.keyType, node.valueType, currentLibrary.nonNullable);
+        node.keyType, node.valueType, currentLibrary!.nonNullable);
     for (Expression part in node.maps) {
       DartType partType = visitExpression(part);
       checkAssignable(node, type, partType);
@@ -749,7 +744,7 @@
       checkAssignable(node, fieldType, valueType);
     });
     return new InterfaceType(
-        node.classNode, currentLibrary.nonNullable, node.typeArguments);
+        node.classNode, currentLibrary!.nonNullable, node.typeArguments);
   }
 
   @override
@@ -764,38 +759,38 @@
 
   @override
   DartType visitSuperMethodInvocation(SuperMethodInvocation node) {
-    if (node.interfaceTarget == null) {
-      checkUnresolvedInvocation(currentThisType, node);
-      return handleDynamicCall(currentThisType, node.arguments);
+    Member? target = node.interfaceTarget;
+    if (target == null) {
+      checkUnresolvedInvocation(currentThisType!, node);
+      return handleDynamicCall(currentThisType!, node.arguments);
     } else {
-      return handleCall(node.arguments, node.interfaceTarget.getterType,
-          receiver: getSuperReceiverType(node.interfaceTarget));
+      return handleCall(node.arguments, target.getterType,
+          receiver: getSuperReceiverType(target));
     }
   }
 
   @override
   DartType visitSuperPropertyGet(SuperPropertyGet node) {
-    if (node.interfaceTarget == null) {
-      checkUnresolvedInvocation(currentThisType, node);
+    Member? target = node.interfaceTarget;
+    if (target == null) {
+      checkUnresolvedInvocation(currentThisType!, node);
       return const DynamicType();
     } else {
-      Substitution receiver = getSuperReceiverType(node.interfaceTarget);
-      return receiver.substituteType(node.interfaceTarget.getterType);
+      Substitution receiver = getSuperReceiverType(target);
+      return receiver.substituteType(target.getterType);
     }
   }
 
   @override
   DartType visitSuperPropertySet(SuperPropertySet node) {
+    Member? target = node.interfaceTarget;
     DartType value = visitExpression(node.value);
-    if (node.interfaceTarget != null) {
-      Substitution receiver = getSuperReceiverType(node.interfaceTarget);
-      checkAssignable(
-          node.value,
-          value,
-          receiver.substituteType(node.interfaceTarget.setterType,
-              contravariant: true));
+    if (target != null) {
+      Substitution receiver = getSuperReceiverType(target);
+      checkAssignable(node.value, value,
+          receiver.substituteType(target.setterType, contravariant: true));
     } else {
-      checkUnresolvedInvocation(currentThisType, node);
+      checkUnresolvedInvocation(currentThisType!, node);
     }
     return value;
   }
@@ -807,13 +802,13 @@
 
   @override
   DartType visitThisExpression(ThisExpression node) {
-    return currentThisType;
+    return currentThisType!;
   }
 
   @override
   DartType visitThrow(Throw node) {
     visitExpression(node.expression);
-    return NeverType.fromNullability(currentLibrary.nonNullable);
+    return NeverType.fromNullability(currentLibrary!.nonNullable);
   }
 
   @override
@@ -836,7 +831,7 @@
   @override
   DartType visitLoadLibrary(LoadLibrary node) {
     return environment.futureType(
-        const DynamicType(), currentLibrary.nonNullable);
+        const DynamicType(), currentLibrary!.nonNullable);
   }
 
   @override
@@ -853,7 +848,7 @@
   visitAssertStatement(AssertStatement node) {
     visitExpression(node.condition);
     if (node.message != null) {
-      visitExpression(node.message);
+      visitExpression(node.message!);
     }
   }
 
@@ -907,25 +902,25 @@
 
   DartType getIterableElementType(DartType iterable) {
     if (iterable is InterfaceType) {
-      Member iteratorGetter =
+      Member? iteratorGetter =
           hierarchy.getInterfaceMember(iterable.classNode, iteratorName);
       if (iteratorGetter == null) return const DynamicType();
       List<DartType> castedIterableArguments =
           hierarchy.getTypeArgumentsAsInstanceOf(
-              iterable, iteratorGetter.enclosingClass);
+              iterable, iteratorGetter.enclosingClass!)!;
       DartType iteratorType = Substitution.fromPairs(
-              iteratorGetter.enclosingClass.typeParameters,
+              iteratorGetter.enclosingClass!.typeParameters,
               castedIterableArguments)
           .substituteType(iteratorGetter.getterType);
       if (iteratorType is InterfaceType) {
-        Member currentGetter =
+        Member? currentGetter =
             hierarchy.getInterfaceMember(iteratorType.classNode, currentName);
         if (currentGetter == null) return const DynamicType();
         List<DartType> castedIteratorTypeArguments =
             hierarchy.getTypeArgumentsAsInstanceOf(
-                iteratorType, currentGetter.enclosingClass);
+                iteratorType, currentGetter.enclosingClass!)!;
         return Substitution.fromPairs(
-                currentGetter.enclosingClass.typeParameters,
+                currentGetter.enclosingClass!.typeParameters,
                 castedIteratorTypeArguments)
             .substituteType(currentGetter.getterType);
       }
@@ -935,7 +930,7 @@
 
   DartType getStreamElementType(DartType stream) {
     if (stream is InterfaceType) {
-      List<DartType> asStreamArguments =
+      List<DartType>? asStreamArguments =
           hierarchy.getTypeArgumentsAsInstanceOf(stream, coreTypes.streamClass);
       if (asStreamArguments == null) return const DynamicType();
       return asStreamArguments.single;
@@ -948,7 +943,7 @@
     node.variables.forEach(visitVariableDeclaration);
     if (node.condition != null) {
       node.condition = checkAndDowncastExpression(
-          node.condition, environment.coreTypes.boolLegacyRawType);
+          node.condition!, environment.coreTypes.boolLegacyRawType);
     }
     node.updates.forEach(visitExpression);
     visitStatement(node.body);
@@ -965,7 +960,7 @@
         node.condition, environment.coreTypes.boolLegacyRawType);
     visitStatement(node.then);
     if (node.otherwise != null) {
-      visitStatement(node.otherwise);
+      visitStatement(node.otherwise!);
     }
   }
 
@@ -976,15 +971,16 @@
 
   @override
   visitReturnStatement(ReturnStatement node) {
-    if (node.expression != null) {
+    Expression? expression = node.expression;
+    if (expression != null) {
       if (currentReturnType == null) {
         fail(node, 'Return of a value from void method');
       } else {
-        DartType type = visitExpression(node.expression);
+        DartType type = visitExpression(expression);
         if (currentAsyncMarker == AsyncMarker.Async) {
           type = environment.flatten(type);
         }
-        checkAssignable(node.expression, type, currentReturnType);
+        checkAssignable(expression, type, currentReturnType!);
       }
     }
   }
@@ -1016,7 +1012,7 @@
   visitVariableDeclaration(VariableDeclaration node) {
     if (node.initializer != null) {
       node.initializer =
-          checkAndDowncastExpression(node.initializer, node.type);
+          checkAndDowncastExpression(node.initializer!, node.type);
     }
   }
 
@@ -1034,18 +1030,18 @@
           ? coreTypes.streamClass
           : coreTypes.iterableClass;
       DartType type = visitExpression(node.expression);
-      List<DartType> asContainerArguments = type is InterfaceType
+      List<DartType>? asContainerArguments = type is InterfaceType
           ? hierarchy.getTypeArgumentsAsInstanceOf(type, container)
           : null;
       if (asContainerArguments != null) {
         checkAssignable(
-            node.expression, asContainerArguments[0], currentYieldType);
+            node.expression, asContainerArguments[0], currentYieldType!);
       } else {
         fail(node.expression, '$type is not an instance of $container');
       }
     } else {
       node.expression =
-          checkAndDowncastExpression(node.expression, currentYieldType);
+          checkAndDowncastExpression(node.expression, currentYieldType!);
     }
   }
 
diff --git a/tools/VERSION b/tools/VERSION
index 4343132..7944ac2 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 14
 PATCH 0
-PRERELEASE 55
+PRERELEASE 56
 PRERELEASE_PATCH 0
\ No newline at end of file