Version 2.13.0-221.0.dev

Merge commit '37700c4314ddb0430bc448fc0a708a8361f26a05' into 'dev'
diff --git a/DEPS b/DEPS
index 4ca4eda..b63cd01 100644
--- a/DEPS
+++ b/DEPS
@@ -45,7 +45,7 @@
   # hashes. It requires access to the dart-build-access group, which EngProd
   # has.
   "co19_rev": "812ab751c41fe8d706fd1e4aae62d2dea2887ac2",
-  "co19_2_rev": "3642f24e2e6273c6fb65a8f60cd0edc95153942e",
+  "co19_2_rev": "f7f583366396cb1457e58c9bfb6d6e53dc21d741",
 
   # The internal benchmarks to use. See go/dart-benchmarks-internal
   "benchmarks_internal_rev": "076df10d9b77af337f2d8029725787155eb1cd52",
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
index 76c3ebc..31f5089 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
@@ -576,7 +576,7 @@
       });
 
       test('on implicit this/super', () {
-        var h = Harness();
+        var h = Harness(thisType: 'C')..addMember('C', 'f', 'Object?');
         h.run([
           if_(thisOrSuperPropertyGet('f').is_('Null'), [
             if_(thisOrSuperPropertyGet('f').eq(nullLiteral), [
@@ -1511,7 +1511,7 @@
       });
 
       test('on implicit this/super', () {
-        var h = Harness();
+        var h = Harness(thisType: 'C')..addMember('C', 'f', 'Object?');
         h.run([
           if_(thisOrSuperPropertyGet('f').is_('Never'), [
             checkReachable(true),
@@ -5613,7 +5613,7 @@
       });
 
       test('via implicit this/super', () {
-        var h = Harness();
+        var h = Harness(thisType: 'C')..addMember('C', 'field', 'Object?');
         h.run([
           if_(thisOrSuperPropertyGet('field').eq(nullLiteral), [
             return_(),
diff --git a/pkg/_fe_analyzer_shared/test/mini_ast.dart b/pkg/_fe_analyzer_shared/test/mini_ast.dart
index a43f4ac..a7f5ac3 100644
--- a/pkg/_fe_analyzer_shared/test/mini_ast.dart
+++ b/pkg/_fe_analyzer_shared/test/mini_ast.dart
@@ -149,8 +149,8 @@
         {required bool isExhaustive}) =>
     new _Switch(expression, cases, isExhaustive);
 
-Expression thisOrSuperPropertyGet(String name, {String type = 'Object?'}) =>
-    new _ThisOrSuperPropertyGet(name, Type(type));
+Expression thisOrSuperPropertyGet(String name) =>
+    new _ThisOrSuperPropertyGet(name);
 
 Expression throw_(Expression operand) => new _Throw(operand);
 
@@ -1575,15 +1575,14 @@
 class _ThisOrSuperPropertyGet extends Expression {
   final String propertyName;
 
-  final Type type;
-
-  _ThisOrSuperPropertyGet(this.propertyName, this.type);
+  _ThisOrSuperPropertyGet(this.propertyName);
 
   @override
   void _preVisit(AssignedVariables<Node, Var> assignedVariables) {}
 
   @override
   Type _visit(Harness h) {
+    var type = h.getMember(h.thisType!, propertyName);
     h._flow.thisOrSuperPropertyGet(this, propertyName, propertyName, type);
     return type;
   }
@@ -1614,7 +1613,6 @@
   final Statement _body;
   final List<_CatchClause> _catches;
   final Statement? _finally;
-  final _bodyNode = Node._();
 
   _TryStatement(this._body, this._catches, this._finally) : super._();
 
@@ -1641,7 +1639,7 @@
       assignedVariables.beginNode();
     }
     _body._preVisit(assignedVariables);
-    assignedVariables.endNode(_bodyNode);
+    assignedVariables.endNode(_body);
     for (var catch_ in _catches) {
       catch_._preVisit(assignedVariables);
     }
@@ -1663,15 +1661,15 @@
     }
     _body._visit(h);
     if (_catches.isNotEmpty) {
-      h._flow.tryCatchStatement_bodyEnd(_bodyNode);
+      h._flow.tryCatchStatement_bodyEnd(_body);
       for (var catch_ in _catches) {
         catch_._visit(h);
       }
       h._flow.tryCatchStatement_end();
     }
     if (_finally != null) {
-      h._flow.tryFinallyStatement_finallyBegin(
-          _catches.isNotEmpty ? this : _bodyNode);
+      h._flow
+          .tryFinallyStatement_finallyBegin(_catches.isNotEmpty ? this : _body);
       _finally!._visit(h);
       h._flow.tryFinallyStatement_end();
     }
diff --git a/pkg/analysis_server/lib/src/provisional/completion/dart/completion_dart.dart b/pkg/analysis_server/lib/src/provisional/completion/dart/completion_dart.dart
index de9c92b..cf8cad0 100644
--- a/pkg/analysis_server/lib/src/provisional/completion/dart/completion_dart.dart
+++ b/pkg/analysis_server/lib/src/provisional/completion/dart/completion_dart.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/src/provisional/completion/completion_core.dart';
 import 'package:analysis_server/src/services/completion/dart/feature_computer.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
@@ -35,14 +33,14 @@
 
   /// Return the type imposed on the target's `containingNode` based on its
   /// context, or `null` if the context does not impose any type.
-  DartType get contextType;
+  DartType? get contextType;
 
   /// Return the object used to resolve macros in Dartdoc comments.
   DartdocDirectiveInfo get dartdocDirectiveInfo;
 
   /// Return the expression to the right of the "dot" or "dot dot",
   /// or `null` if this is not a "dot" completion (e.g. `foo.b`).
-  Expression get dotTarget;
+  Expression? get dotTarget;
 
   /// Return the object used to compute the values of the features used to
   /// compute relevance scores for suggestions.
@@ -61,13 +59,13 @@
   /// Return the library element which contains the unit in which the completion
   /// is occurring. This may return `null` if the library cannot be determined
   /// (e.g. unlinked part file).
-  LibraryElement get libraryElement;
+  LibraryElement? get libraryElement;
 
   /// The source for the library containing the completion request.
   /// This may be different from the source in which the completion is requested
   /// if the completion is being requested in a part file.
   /// This may be `null` if the library for a part file cannot be determined.
-  Source get librarySource;
+  Source? get librarySource;
 
   /// Answer the [DartType] for Object in dart:core
   DartType get objectType;
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
index 5274710..e47f4f0 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.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/src/provisional/completion/completion_core.dart';
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
@@ -17,15 +15,15 @@
 /// correspond to named parameters when completing in argument lists.
 class ArgListContributor extends DartCompletionContributor {
   /// The request that is currently being handled.
-  DartCompletionRequest request;
+  late DartCompletionRequest request;
 
   /// The suggestion builder used to build suggestions.
-  SuggestionBuilder builder;
+  late SuggestionBuilder builder;
 
   /// The argument list that is the containing node of the target, or `null` if
   /// the containing node of the target is not an argument list (such as when
   /// it's a named expression).
-  ArgumentList argumentList;
+  ArgumentList? argumentList;
 
   @override
   Future<void> computeSuggestions(
@@ -47,7 +45,7 @@
   }
 
   void _addDefaultParamSuggestions(Iterable<ParameterElement> parameters,
-      {bool appendComma = false, int replacementLength}) {
+      {bool appendComma = false, int? replacementLength}) {
     var appendColon = !_isInNamedExpression();
     var namedArgs = _namedArgs();
     for (var parameter in parameters) {
@@ -61,7 +59,7 @@
 
   void _addNamedParameterSuggestion(List<String> namedArgs,
       ParameterElement parameter, bool appendColon, bool appendComma,
-      {int replacementLength}) {
+      {int? replacementLength}) {
     var name = parameter.name;
 
     // Check whether anything after the caret is being replaced. If so, we will
@@ -74,7 +72,7 @@
         request.completionPreference == CompletionPreference.replace &&
             replacementEnd > request.offset;
 
-    if (name != null && name.isNotEmpty && !namedArgs.contains(name)) {
+    if (name.isNotEmpty && !namedArgs.contains(name)) {
       builder.suggestNamedArgument(parameter,
           // If there's a replacement length and the preference is to replace,
           // we should not include colons/commas.
@@ -85,7 +83,7 @@
   }
 
   void _addSuggestions(Iterable<ParameterElement> parameters) {
-    if (parameters == null || parameters.isEmpty) {
+    if (parameters.isEmpty) {
       return;
     }
     var requiredParam =
@@ -110,7 +108,7 @@
         // for an identifier that is not the named label and therefore it should
         // not be replaced.
         var replacementLength =
-            request.offset == request.target.entity.offset &&
+            request.offset == request.target.entity?.offset &&
                     request.replacementRange.length != 0
                 ? 0
                 : null;
@@ -135,6 +133,7 @@
 
   /// Return the number of arguments in the argument list.
   int _argCount() {
+    var argumentList = this.argumentList;
     if (argumentList != null) {
       var paren = argumentList.rightParenthesis;
       if (request.target.entity == paren) {
@@ -157,11 +156,15 @@
     }
   }
 
-  /// Return `true` if the caret is preceeding an arg where a name could be added
+  /// Return `true` if the caret is preceding an arg where a name could be added
   /// (turning a positional arg into a named arg).
   bool _isAddingLabelToPositional() {
+    var argumentList = this.argumentList;
     if (argumentList != null) {
       var entity = request.target.entity;
+      if (entity is! Expression) {
+        return false;
+      }
       if (entity is! NamedExpression) {
         // Caret is in front of a value
         //     f(one: 1, ^2);
@@ -191,6 +194,7 @@
   /// Return `true` if the completion target is at the end of the list of
   /// arguments.
   bool _isAppendingToArgList() {
+    var argumentList = this.argumentList;
     if (argumentList != null) {
       var entity = request.target.entity;
       if (entity == argumentList.rightParenthesis) {
@@ -231,17 +235,16 @@
         : entity is Token
             ? entity
             : null;
-    return (token != containingNode?.endToken) &&
+    return (token != containingNode.endToken) &&
         token?.next?.type == TokenType.COMMA &&
-        !token.next.isSynthetic;
+        !(token?.next?.isSynthetic ?? false);
   }
 
   bool _isInFlutterCreation() {
     var flutter = Flutter.instance;
-    var containingNode = request.target?.containingNode;
-    var newExpr = containingNode != null
-        ? flutter.identifyNewExpression(containingNode.parent)
-        : null;
+    var containingNode = request.target.containingNode;
+    var parent = containingNode.parent;
+    var newExpr = parent != null ? flutter.identifyNewExpression(parent) : null;
     return newExpr != null && flutter.isWidgetCreation(newExpr);
   }
 
@@ -272,10 +275,11 @@
   /// [_isInsertingToArgListWithNoSynthetic] have been called and both returned
   /// `false`.
   bool _isInsertingToArgListWithSynthetic() {
+    var argumentList = this.argumentList;
     if (argumentList != null) {
       var entity = request.target.entity;
       if (entity is SimpleIdentifier) {
-        var argIndex = request.target.argIndex;
+        var argIndex = request.target.argIndex!;
         // if the next argument is a NamedExpression, then we are in the named
         // parameter list, guard first against end of list
         if (argumentList.arguments.length == argIndex + 1 ||
@@ -291,6 +295,7 @@
   /// Return a list containing the currently specified named arguments.
   List<String> _namedArgs() {
     var namedArgs = <String>[];
+    var argumentList = this.argumentList;
     if (argumentList != null) {
       for (var arg in argumentList.arguments) {
         if (arg is NamedExpression) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
index c774a4e..3f08723 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.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/src/protocol_server.dart'
     hide Element, ElementKind;
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -24,7 +22,7 @@
     // Build the list of suggestions.
     var directive = node.thisOrAncestorOfType<NamespaceDirective>();
     if (directive is NamespaceDirective) {
-      var library = directive.uriElement as LibraryElement;
+      var library = directive.uriElement as LibraryElement?;
       if (library != null) {
         var existingNames = _getCombinatorNames(directive);
         for (var element in library.exportNamespace.definedNames.values) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart
index e0232fb..b9f376a 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analyzer/dart/ast/ast.dart';
@@ -12,12 +10,13 @@
 import 'package:analyzer/src/dart/element/generic_inferrer.dart'
     show GenericInferrer;
 import 'package:analyzer/src/dart/element/type_algebra.dart';
+import 'package:analyzer/src/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/resolver/scope.dart';
 
 /// A contributor that produces suggestions based on the members of an
 /// extension.
 class ExtensionMemberContributor extends DartCompletionContributor {
-  MemberSuggestionBuilder memberBuilder;
+  late MemberSuggestionBuilder memberBuilder;
 
   @override
   Future<void> computeSuggestions(
@@ -38,8 +37,10 @@
       var classOrMixin = request.target.containingNode
           .thisOrAncestorOfType<ClassOrMixinDeclaration>();
       if (classOrMixin != null) {
-        var type = classOrMixin.declaredElement.thisType;
-        _addExtensionMembers(containingLibrary, type);
+        var type = classOrMixin.declaredElement?.thisType;
+        if (type != null) {
+          _addExtensionMembers(containingLibrary, type);
+        }
       } else {
         var extension = request.target.containingNode
             .thisOrAncestorOfType<ExtensionDeclaration>();
@@ -76,7 +77,10 @@
       }
     }
     if (expression is ExtensionOverride) {
-      _addInstanceMembers(expression.staticElement, 0.0);
+      var staticElement = expression.staticElement;
+      if (staticElement != null) {
+        _addInstanceMembers(staticElement, 0.0);
+      }
     } else {
       var type = expression.staticType;
       if (type == null) {
@@ -140,13 +144,14 @@
   /// Use the [type] of the object being extended in the [library] to compute
   /// the actual type extended by the [extension]. Return the computed type,
   /// or `null` if the type cannot be computed.
-  DartType _resolveExtendedType(
+  DartType? _resolveExtendedType(
     LibraryElement library,
     ExtensionElement extension,
     DartType type,
   ) {
     var typeParameters = extension.typeParameters;
-    var inferrer = GenericInferrer(library.typeSystem, typeParameters);
+    var inferrer =
+        GenericInferrer(library.typeSystem as TypeSystemImpl, typeParameters);
     inferrer.constrainArgument(
       type,
       extension.extendedType,
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
index 9fd0c36..f6d2263 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
@@ -314,7 +314,7 @@
 
   /// Return the value of the _is noSuchMethod_ feature.
   double isNoSuchMethodFeature(
-      String containingMethodName, String proposedMemberName) {
+      String? containingMethodName, String proposedMemberName) {
     if (proposedMemberName == containingMethodName) {
       // Don't penalize `noSuchMethod` when completing after `super` in an
       // override of `noSuchMethod`.
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/field_formal_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/field_formal_contributor.dart
index b322111..e722f99 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/field_formal_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/field_formal_contributor.dart
@@ -2,11 +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:analysis_server/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/element/element.dart';
 
 /// A contributor that produces suggestions for field formal parameters that are
 /// based on the fields declared directly by the enclosing class that are not
@@ -35,13 +34,13 @@
     var referencedFields = <String>[];
     for (var param in constructor.parameters.parameters) {
       if (param is DefaultFormalParameter) {
-        param = (param as DefaultFormalParameter).parameter;
+        param = param.parameter;
       }
       if (param is FieldFormalParameter) {
         var fieldId = param.identifier;
-        if (fieldId != null && fieldId != request.target.entity) {
+        if (fieldId != request.target.entity) {
           var fieldName = fieldId.name;
-          if (fieldName != null && fieldName.isNotEmpty) {
+          if (fieldName.isNotEmpty) {
             referencedFields.add(fieldName);
           }
         }
@@ -58,9 +57,9 @@
       if (member is FieldDeclaration && !member.isStatic) {
         for (var variable in member.fields.variables) {
           var field = variable.name.staticElement;
-          if (field != null) {
+          if (field is FieldElement) {
             var fieldName = field.name;
-            if (fieldName != null && fieldName.isNotEmpty) {
+            if (fieldName.isNotEmpty) {
               if (!referencedFields.contains(fieldName)) {
                 builder.suggestFieldFormalParameter(field);
               }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart
index dd993ba..deb2cb7 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/imported_reference_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/local_library_contributor.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart'
@@ -19,7 +17,7 @@
       return;
     }
 
-    var imports = request.libraryElement.imports;
+    var imports = request.libraryElement?.imports;
     if (imports == null) {
       return;
     }
@@ -36,7 +34,7 @@
 
   void _buildSuggestions(DartCompletionRequest request,
       SuggestionBuilder builder, Namespace namespace,
-      {String prefix}) {
+      {String? prefix}) {
     var visitor = LibraryElementSuggestionBuilder(request, builder, prefix);
     for (var elem in namespace.definedNames.values) {
       elem.accept(visitor);
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart
index 634cae3..18ebdde 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.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/src/protocol_server.dart'
     show CompletionSuggestionKind;
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -29,10 +27,7 @@
         // determined (e.g. detached part file or source change).
         if (containingLibrary != null) {
           var imports = containingLibrary.imports;
-          if (imports != null) {
-            _buildSuggestions(request, builder, elem, imports);
-            return;
-          }
+          _buildSuggestions(request, builder, elem, imports);
         }
       }
     }
@@ -45,7 +40,7 @@
       List<ImportElement> imports) {
     var parent = request.target.containingNode.parent;
     var typesOnly = parent is TypeName;
-    var isConstructor = parent.parent is ConstructorName;
+    var isConstructor = parent?.parent is ConstructorName;
     for (var importElem in imports) {
       if (importElem.prefix?.name == elem.name) {
         var library = importElem.importedLibrary;
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/library_prefix_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/library_prefix_contributor.dart
index 2ec7b23..d8a09fb 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/library_prefix_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/library_prefix_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 
@@ -17,7 +15,7 @@
       return;
     }
 
-    var imports = request.libraryElement.imports;
+    var imports = request.libraryElement?.imports;
     if (imports == null) {
       return;
     }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
index 279f4fb..c767698 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.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/src/protocol_server.dart'
     show CompletionSuggestionKind;
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -25,18 +23,25 @@
 
   CompletionSuggestionKind kind;
 
-  final String prefix;
+  final String? prefix;
 
   /// The set of libraries that have been, or are currently being, visited.
   final Set<LibraryElement> visitedLibraries = <LibraryElement>{};
 
-  LibraryElementSuggestionBuilder(this.request, this.builder, [this.prefix])
-      : opType = request.opType {
-    kind = request.target.isFunctionalArgument()
+  factory LibraryElementSuggestionBuilder(
+      DartCompletionRequest request, SuggestionBuilder builder,
+      [String? prefix]) {
+    var opType = request.opType;
+    var kind = request.target.isFunctionalArgument()
         ? CompletionSuggestionKind.IDENTIFIER
         : opType.suggestKind;
+    return LibraryElementSuggestionBuilder._(
+        request, builder, opType, kind, prefix);
   }
 
+  LibraryElementSuggestionBuilder._(
+      this.request, this.builder, this.opType, this.kind, this.prefix);
+
   @override
   void visitClassElement(ClassElement element) {
     if (opType.includeTypeNameSuggestions) {
@@ -84,7 +89,7 @@
       return;
     }
     var returnType = element.returnType;
-    if (returnType != null && returnType.isVoid) {
+    if (returnType.isVoid) {
       if (opType.includeVoidReturnSuggestions) {
         builder.suggestTopLevelFunction(element, kind: kind, prefix: prefix);
       }
@@ -153,14 +158,14 @@
       return;
     }
 
-    var libraryUnits = request.result.unit.declaredElement.library.units;
+    var libraryUnits = request.result.unit?.declaredElement?.library.units;
     if (libraryUnits == null) {
       return;
     }
 
     var visitor = LibraryElementSuggestionBuilder(request, builder);
     for (var unit in libraryUnits) {
-      if (unit != null && unit.source != request.source) {
+      if (unit.source != request.source) {
         unit.accept(visitor);
       }
     }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
index 546c236..728ea51 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.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/src/protocol_server.dart'
     show CompletionSuggestionKind;
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -15,7 +13,6 @@
 import 'package:analyzer_plugin/src/utilities/completion/optype.dart';
 import 'package:analyzer_plugin/src/utilities/visitors/local_declaration_visitor.dart'
     show LocalDeclarationVisitor;
-import 'package:meta/meta.dart';
 
 /// A contributor that produces suggestions based on the declarations in the
 /// local file and containing library.  This contributor also produces
@@ -24,10 +21,10 @@
 /// inherited instance member might be invoked via an implicit target of `this`.
 class LocalReferenceContributor extends DartCompletionContributor {
   /// The builder used to build some suggestions.
-  MemberSuggestionBuilder memberBuilder;
+  late MemberSuggestionBuilder memberBuilder;
 
   /// The kind of suggestion to make.
-  CompletionSuggestionKind classMemberSuggestionKind;
+  CompletionSuggestionKind? classMemberSuggestionKind;
 
   /// The [_VisibilityTracker] tracks the set of elements already added in the
   /// completion list, this object helps prevents suggesting elements that have
@@ -38,7 +35,7 @@
   Future<void> computeSuggestions(
       DartCompletionRequest request, SuggestionBuilder builder) async {
     var opType = request.opType;
-    var node = request.target.containingNode;
+    AstNode? node = request.target.containingNode;
 
     // Suggest local fields for constructor initializers.
     var suggestLocalFields = node is ConstructorDeclaration &&
@@ -62,16 +59,19 @@
         if (node is ForStatement && node.forLoopParts is ForEachParts) {
           node = node.parent;
         } else if (node is ForEachParts) {
-          node = node.parent.parent;
+          node = node.parent?.parent;
         }
 
-        try {
-          builder.laterReplacesEarlier = false;
-          var localVisitor = _LocalVisitor(request, builder, visibilityTracker,
-              suggestLocalFields: suggestLocalFields);
-          localVisitor.visit(node);
-        } finally {
-          builder.laterReplacesEarlier = true;
+        if (node != null) {
+          try {
+            builder.laterReplacesEarlier = false;
+            var localVisitor = _LocalVisitor(
+                request, builder, visibilityTracker,
+                suggestLocalFields: suggestLocalFields);
+            localVisitor.visit(node);
+          } finally {
+            builder.laterReplacesEarlier = true;
+          }
         }
       }
     }
@@ -81,10 +81,12 @@
       var member = _enclosingMember(request.target);
       if (member != null) {
         var classOrMixin = member.parent;
-        if (classOrMixin is ClassOrMixinDeclaration &&
-            classOrMixin.declaredElement != null) {
-          memberBuilder = MemberSuggestionBuilder(request, builder);
-          _computeSuggestionsForClass(classOrMixin.declaredElement, request);
+        if (classOrMixin is ClassOrMixinDeclaration) {
+          var declaredElement = classOrMixin.declaredElement;
+          if (declaredElement != null) {
+            memberBuilder = MemberSuggestionBuilder(request, builder);
+            _computeSuggestionsForClass(declaredElement, request);
+          }
         }
       }
     }
@@ -113,12 +115,7 @@
     }
     for (var method in type.methods) {
       if (visibilityTracker._isVisible(method.declaration)) {
-        if (method.returnType == null) {
-          memberBuilder.addSuggestionForMethod(
-              method: method,
-              inheritanceDistance: inheritanceDistance,
-              kind: classMemberSuggestionKind);
-        } else if (!method.returnType.isVoid) {
+        if (!method.returnType.isVoid) {
           if (opType.includeReturnValueSuggestions) {
             memberBuilder.addSuggestionForMethod(
                 method: method,
@@ -153,8 +150,8 @@
 
   /// Return the class member containing the target or `null` if the target is
   /// in a static method or static field or not in a class member.
-  ClassMember _enclosingMember(CompletionTarget target) {
-    var node = target.containingNode;
+  ClassMember? _enclosingMember(CompletionTarget target) {
+    AstNode? node = target.containingNode;
     while (node != null) {
       if (node is MethodDeclaration) {
         if (!node.isStatic) {
@@ -199,9 +196,8 @@
   _VisibilityTracker visibilityTracker;
 
   _LocalVisitor(this.request, this.builder, this.visibilityTracker,
-      {@required this.suggestLocalFields})
-      : assert(visibilityTracker != null),
-        opType = request.opType,
+      {required this.suggestLocalFields})
+      : opType = request.opType,
         targetIsFunctionalArgument = request.target.isFunctionalArgument(),
         super(request.offset);
 
@@ -212,7 +208,7 @@
   @override
   void declaredClass(ClassDeclaration declaration) {
     var classElt = declaration.declaredElement;
-    if (visibilityTracker._isVisible(classElt)) {
+    if (classElt != null && visibilityTracker._isVisible(classElt)) {
       if (opType.includeTypeNameSuggestions) {
         builder.suggestClass(classElt, kind: _defaultKind);
       }
@@ -233,8 +229,9 @@
 
   @override
   void declaredClassTypeAlias(ClassTypeAlias declaration) {
-    if (opType.includeTypeNameSuggestions) {
-      builder.suggestClass(declaration.declaredElement, kind: _defaultKind);
+    var declaredElement = declaration.declaredElement;
+    if (declaredElement != null && opType.includeTypeNameSuggestions) {
+      builder.suggestClass(declaredElement, kind: _defaultKind);
     }
   }
 
@@ -245,12 +242,17 @@
 
   @override
   void declaredEnum(EnumDeclaration declaration) {
-    if (visibilityTracker._isVisible(declaration.declaredElement) &&
+    var declaredElement = declaration.declaredElement;
+    if (declaredElement != null &&
+        visibilityTracker._isVisible(declaredElement) &&
         opType.includeTypeNameSuggestions) {
-      builder.suggestClass(declaration.declaredElement, kind: _defaultKind);
+      builder.suggestClass(declaredElement, kind: _defaultKind);
       for (var enumConstant in declaration.constants) {
         if (!enumConstant.isSynthetic) {
-          builder.suggestEnumConstant(enumConstant.declaredElement);
+          var constantElement = enumConstant.declaredElement;
+          if (constantElement is FieldElement) {
+            builder.suggestEnumConstant(constantElement);
+          }
         }
       }
     }
@@ -258,27 +260,33 @@
 
   @override
   void declaredExtension(ExtensionDeclaration declaration) {
-    if (visibilityTracker._isVisible(declaration.declaredElement) &&
+    var declaredElement = declaration.declaredElement;
+    if (declaredElement != null &&
+        visibilityTracker._isVisible(declaredElement) &&
         opType.includeReturnValueSuggestions &&
         declaration.name != null) {
-      builder.suggestExtension(declaration.declaredElement, kind: _defaultKind);
+      builder.suggestExtension(declaredElement, kind: _defaultKind);
     }
   }
 
   @override
   void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) {
     var field = varDecl.declaredElement;
-    if ((visibilityTracker._isVisible(field) &&
-            opType.includeReturnValueSuggestions &&
-            (!opType.inStaticMethodBody || fieldDecl.isStatic)) ||
-        suggestLocalFields) {
+    if (field is FieldElement &&
+        ((visibilityTracker._isVisible(field) &&
+                opType.includeReturnValueSuggestions &&
+                (!opType.inStaticMethodBody || fieldDecl.isStatic)) ||
+            suggestLocalFields)) {
       var inheritanceDistance = 0.0;
       var enclosingClass = request.target.containingNode
           .thisOrAncestorOfType<ClassDeclaration>();
-      if (enclosingClass != null) {
-        inheritanceDistance = request.featureComputer
-            .inheritanceDistanceFeature(
-                enclosingClass.declaredElement, field.enclosingElement);
+      var enclosingElement = enclosingClass?.declaredElement;
+      if (enclosingElement != null) {
+        var enclosingElement = field.enclosingElement;
+        if (enclosingElement is ClassElement) {
+          inheritanceDistance = request.featureComputer
+              .inheritanceDistanceFeature(enclosingElement, enclosingElement);
+        }
       }
       builder.suggestField(field, inheritanceDistance: inheritanceDistance);
     }
@@ -311,15 +319,18 @@
 
   @override
   void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
-    if (opType.includeTypeNameSuggestions) {
-      builder.suggestTypeAlias(declaration.declaredElement, kind: _defaultKind);
+    var declaredElement = declaration.declaredElement;
+    if (declaredElement != null && opType.includeTypeNameSuggestions) {
+      builder.suggestTypeAlias(declaredElement, kind: _defaultKind);
     }
   }
 
   @override
   void declaredGenericTypeAlias(GenericTypeAlias declaration) {
-    if (opType.includeTypeNameSuggestions) {
-      builder.suggestTypeAlias(declaration.declaredElement, kind: _defaultKind);
+    var declaredElement = declaration.declaredElement;
+    if (declaredElement is TypeAliasElement &&
+        opType.includeTypeNameSuggestions) {
+      builder.suggestTypeAlias(declaredElement, kind: _defaultKind);
     }
   }
 
@@ -329,10 +340,10 @@
   }
 
   @override
-  void declaredLocalVar(SimpleIdentifier id, TypeAnnotation typeName) {
-    if (visibilityTracker._isVisible(id.staticElement) &&
+  void declaredLocalVar(SimpleIdentifier name, TypeAnnotation? type) {
+    if (visibilityTracker._isVisible(name.staticElement) &&
         opType.includeReturnValueSuggestions) {
-      builder.suggestLocalVariable(id.staticElement as LocalVariableElement);
+      builder.suggestLocalVariable(name.staticElement as LocalVariableElement);
     }
   }
 
@@ -347,9 +358,12 @@
       var enclosingClass = request.target.containingNode
           .thisOrAncestorOfType<ClassDeclaration>();
       if (enclosingClass != null) {
-        inheritanceDistance = request.featureComputer
-            .inheritanceDistanceFeature(
-                enclosingClass.declaredElement, element.enclosingElement);
+        var enclosingElement = element?.enclosingElement;
+        if (enclosingElement is ClassElement) {
+          inheritanceDistance = request.featureComputer
+              .inheritanceDistanceFeature(
+                  enclosingClass.declaredElement!, enclosingElement);
+        }
       }
       if (element is MethodElement) {
         builder.suggestMethod(element,
@@ -363,19 +377,21 @@
 
   @override
   void declaredMixin(MixinDeclaration declaration) {
+    var declaredElement = declaration.declaredElement;
     if (!inExtendsClause &&
-        visibilityTracker._isVisible(declaration.declaredElement) &&
+        declaredElement != null &&
+        visibilityTracker._isVisible(declaredElement) &&
         opType.includeTypeNameSuggestions) {
-      builder.suggestClass(declaration.declaredElement, kind: _defaultKind);
+      builder.suggestClass(declaredElement, kind: _defaultKind);
     }
   }
 
   @override
-  void declaredParam(SimpleIdentifier id, TypeAnnotation typeName) {
-    var element = id.staticElement;
+  void declaredParam(SimpleIdentifier name, TypeAnnotation? type) {
+    var element = name.staticElement;
     if (visibilityTracker._isVisible(element) &&
         opType.includeReturnValueSuggestions) {
-      if (_isUnused(id.name)) {
+      if (_isUnused(name.name)) {
         return;
       }
       if (element is ParameterElement) {
@@ -390,18 +406,23 @@
   void declaredTopLevelVar(
       VariableDeclarationList varList, VariableDeclaration varDecl) {
     var variableElement = varDecl.declaredElement;
-    if (visibilityTracker._isVisible(variableElement) &&
+    if (variableElement is TopLevelVariableElement &&
+        visibilityTracker._isVisible(variableElement) &&
         opType.includeReturnValueSuggestions) {
-      builder.suggestTopLevelPropertyAccessor(
-          (variableElement as TopLevelVariableElement).getter);
+      var getter = variableElement.getter;
+      if (getter != null) {
+        builder.suggestTopLevelPropertyAccessor(getter);
+      }
     }
   }
 
   @override
   void declaredTypeParameter(TypeParameter node) {
-    if (visibilityTracker._isVisible(node.declaredElement) &&
+    var declaredElement = node.declaredElement;
+    if (declaredElement != null &&
+        visibilityTracker._isVisible(declaredElement) &&
         opType.includeTypeNameSuggestions) {
-      builder.suggestTypeParameter(node.declaredElement);
+      builder.suggestTypeParameter(declaredElement);
     }
   }
 
@@ -415,10 +436,10 @@
   /// characters and nothing else.
   bool _isUnused(String identifier) => RegExp(r'^_+$').hasMatch(identifier);
 
-  bool _isVoid(TypeAnnotation returnType) {
+  bool _isVoid(TypeAnnotation? returnType) {
     if (returnType is TypeName) {
       var id = returnType.name;
-      if (id != null && id.name == 'void') {
+      if (id.name == 'void') {
         return true;
       }
     }
@@ -436,6 +457,8 @@
   /// Before completions are added by this contributor, we verify with this
   /// method if the element has already been added, this prevents suggesting
   /// [Element]s that are shadowed.
-  bool _isVisible(Element element) =>
-      element != null && declaredNames.add(element.name);
+  bool _isVisible(Element? element) {
+    var name = element?.name;
+    return name != null && declaredNames.add(name);
+  }
 }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/named_constructor_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/named_constructor_contributor.dart
index b31253f..a0cec5d 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/named_constructor_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/named_constructor_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analyzer/dart/ast/ast.dart';
@@ -24,13 +22,11 @@
         return;
       }
       var typeName = node.type;
-      if (typeName != null) {
-        var type = typeName.type;
-        if (type != null) {
-          var element = type.element;
-          if (element is ClassElement) {
-            _buildSuggestions(request, builder, libraryElement, element);
-          }
+      var type = typeName.type;
+      if (type != null) {
+        var element = type.element;
+        if (element is ClassElement) {
+          _buildSuggestions(request, builder, libraryElement, element);
         }
       }
     }
@@ -45,10 +41,7 @@
     for (var constructor in classElem.constructors) {
       if (isLocalClassDecl || !constructor.isPrivate) {
         if (!classElem.isAbstract || constructor.isFactory) {
-          var name = constructor.name;
-          if (name != null) {
-            builder.suggestConstructor(constructor, hasClassName: true);
-          }
+          builder.suggestConstructor(constructor, hasClassName: true);
         }
       }
     }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
index c18f91d..1cccc64 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analyzer/dart/ast/ast.dart';
@@ -29,6 +27,9 @@
 
     // Generate a collection of inherited members
     var classElem = classDecl.declaredElement;
+    if (classElem == null) {
+      return;
+    }
     var interface = inheritance.getInterface(classElem);
     var interfaceMap = interface.map;
     var namesToOverride =
@@ -38,7 +39,7 @@
     for (var name in namesToOverride) {
       var element = interfaceMap[name];
       // Gracefully degrade if the overridden element has not been resolved.
-      if (element.returnType != null) {
+      if (element != null) {
         var invokeSuper = interface.isSuperImplemented(name);
         await builder.suggestOverride(targetId, element, invokeSuper);
       }
@@ -47,7 +48,7 @@
 
   /// If the target looks like a partial identifier inside a class declaration
   /// then return that identifier, otherwise return `null`.
-  SimpleIdentifier _getTargetId(CompletionTarget target) {
+  SimpleIdentifier? _getTargetId(CompletionTarget target) {
     var node = target.containingNode;
     if (node is ClassOrMixinDeclaration) {
       var entity = target.entity;
@@ -63,7 +64,7 @@
     return null;
   }
 
-  SimpleIdentifier _getTargetIdFromVarList(VariableDeclarationList fields) {
+  SimpleIdentifier? _getTargetIdFromVarList(VariableDeclarationList fields) {
     var variables = fields.variables;
     if (variables.length == 1) {
       var variable = variables[0];
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart
index cfd2a34..08bf0df 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analyzer/dart/ast/ast.dart';
@@ -30,7 +28,7 @@
     if (targetId is Identifier && !request.target.isCascade) {
       var element = targetId.staticElement;
       if (element is TypeAliasElement) {
-        var aliasedType = (element as TypeAliasElement).aliasedType;
+        var aliasedType = element.aliasedType;
         element = aliasedType.element;
       }
       if (element is ClassElement) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index 43af352..d2ce0e3 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.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:collection';
 
 import 'package:_fe_analyzer_shared/src/base/syntactic_entity.dart';
@@ -25,7 +23,6 @@
 import 'package:analyzer/src/util/comment.dart';
 import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
 import 'package:analyzer_plugin/utilities/range_factory.dart';
-import 'package:meta/meta.dart';
 
 /// This class provides suggestions based upon the visible instance members in
 /// an interface type.
@@ -65,8 +62,8 @@
 
   /// Add a suggestion for the given [accessor].
   void addSuggestionForAccessor(
-      {@required PropertyAccessorElement accessor,
-      @required double inheritanceDistance}) {
+      {required PropertyAccessorElement accessor,
+      required double inheritanceDistance}) {
     if (accessor.isAccessibleIn(request.libraryElement)) {
       var member = accessor.isSynthetic ? accessor.variable : accessor;
       if (_shouldAddSuggestion(member)) {
@@ -78,9 +75,9 @@
 
   /// Add a suggestion for the given [method].
   void addSuggestionForMethod(
-      {@required MethodElement method,
-      CompletionSuggestionKind kind,
-      @required double inheritanceDistance}) {
+      {required MethodElement method,
+      CompletionSuggestionKind? kind,
+      required double inheritanceDistance}) {
     if (method.isAccessibleIn(request.libraryElement) &&
         _shouldAddSuggestion(method)) {
       builder.suggestMethod(method,
@@ -108,7 +105,8 @@
         if ((alreadyGenerated & _COMPLETION_TYPE_GETTER) != 0) {
           return false;
         }
-        _completionTypesGenerated[identifier] |= _COMPLETION_TYPE_GETTER;
+        _completionTypesGenerated[identifier] =
+            _completionTypesGenerated[identifier]! | _COMPLETION_TYPE_GETTER;
       } else {
         // Setters, fields, and methods shadow a setter.
         if ((alreadyGenerated & _COMPLETION_TYPE_SETTER) != 0) {
@@ -119,7 +117,8 @@
           // getter.
           return false;
         }
-        _completionTypesGenerated[identifier] |= _COMPLETION_TYPE_SETTER;
+        _completionTypesGenerated[identifier] =
+            _completionTypesGenerated[identifier]! | _COMPLETION_TYPE_SETTER;
       }
     } else if (element is FieldElement) {
       // Fields and methods shadow a field.  A getter/setter pair shadows a
@@ -146,7 +145,7 @@
 
   /// The listener to be notified at certain points in the process of building
   /// suggestions, or `null` if no notification should occur.
-  final SuggestionListener listener;
+  final SuggestionListener? listener;
 
   /// A map from a completion identifier to a completion suggestion.
   final Map<String, CompletionSuggestion> _suggestionMap =
@@ -167,7 +166,7 @@
   /// either the completion location isn't within a member, the target of the
   /// completion isn't `super`, or the name of the member hasn't yet been
   /// computed. In the latter case, [_hasContainingMemberName] will be `false`.
-  String _cachedContainingMemberName;
+  String? _cachedContainingMemberName;
 
   /// Initialize a newly created suggestion builder to build suggestions for the
   /// given [request].
@@ -183,17 +182,14 @@
   /// Return the name of the member containing the completion location, or
   /// `null` if the completion location isn't within a member or if the target
   /// of the completion isn't `super`.
-  String get _containingMemberName {
+  String? get _containingMemberName {
     if (!_hasContainingMemberName) {
       _hasContainingMemberName = true;
       if (request.dotTarget is SuperExpression) {
         var containingMethod = request.target.containingNode
             .thisOrAncestorOfType<MethodDeclaration>();
         if (containingMethod != null) {
-          var id = containingMethod.name;
-          if (id != null) {
-            _cachedContainingMemberName = id.name;
-          }
+          _cachedContainingMemberName = containingMethod.name.name;
         }
       }
     }
@@ -207,7 +203,7 @@
   /// distance feature computed for the accessor or `-1.0` if the accessor is a
   /// static accessor.
   void suggestAccessor(PropertyAccessorElement accessor,
-      {@required double inheritanceDistance}) {
+      {required double inheritanceDistance}) {
     assert(accessor.enclosingElement is ClassElement ||
         accessor.enclosingElement is ExtensionElement);
     if (accessor.isSynthetic) {
@@ -271,7 +267,7 @@
   /// referenced using a prefix, then the [prefix] should be provided.
   void suggestClass(ClassElement classElement,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
-      String prefix}) {
+      String? prefix}) {
     var relevance = _computeTopLevelRelevance(classElement,
         elementType: _instantiateClassElement(classElement));
     _add(_createSuggestion(classElement,
@@ -302,9 +298,9 @@
     }
 
     CompletionSuggestion createSuggestion({
-      @required String completion,
-      @required String displayText,
-      @required int selectionOffset,
+      required String completion,
+      required String displayText,
+      required int selectionOffset,
     }) {
       return CompletionSuggestion(
         CompletionSuggestionKind.INVOCATION,
@@ -339,25 +335,25 @@
   void suggestConstructor(ConstructorElement constructor,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
       bool hasClassName = false,
-      String prefix}) {
+      String? prefix}) {
     // If the class name is already in the text, then we don't support
     // prepending a prefix.
     assert(!hasClassName || prefix == null);
     var enclosingClass = constructor.enclosingElement;
-    var className = enclosingClass?.name;
-    if (className == null || className.isEmpty) {
+    var className = enclosingClass.name;
+    if (className.isEmpty) {
       return;
     }
 
     var completion = constructor.displayName;
-    if (!hasClassName && className != null && className.isNotEmpty) {
-      if (completion == null || completion.isEmpty) {
+    if (!hasClassName && className.isNotEmpty) {
+      if (completion.isEmpty) {
         completion = className;
       } else {
         completion = '$className.$completion';
       }
     }
-    if (completion == null || completion.isEmpty) {
+    if (completion.isEmpty) {
       return;
     }
 
@@ -396,7 +392,7 @@
 
   /// Add a suggestion for an enum [constant]. If the enum can only be
   /// referenced using a prefix, then the [prefix] should be provided.
-  void suggestEnumConstant(FieldElement constant, {String prefix}) {
+  void suggestEnumConstant(FieldElement constant, {String? prefix}) {
     var constantName = constant.name;
     var enumElement = constant.enclosingElement;
     var enumName = enumElement.name;
@@ -412,7 +408,7 @@
   /// referenced using a prefix, then the [prefix] should be provided.
   void suggestExtension(ExtensionElement extension,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
-      String prefix}) {
+      String? prefix}) {
     var relevance = _computeTopLevelRelevance(extension,
         elementType: extension.extendedType);
     _add(_createSuggestion(extension,
@@ -424,8 +420,7 @@
   /// the member containing the reference. The [inheritanceDistance] is the
   /// value of the inheritance distance feature computed for the field (or
   /// `-1.0` if the field is a static field).
-  void suggestField(FieldElement field,
-      {@required double inheritanceDistance}) {
+  void suggestField(FieldElement field, {required double inheritanceDistance}) {
     var featureComputer = request.featureComputer;
     var contextType =
         featureComputer.contextTypeFeature(request.contextType, field.type);
@@ -485,8 +480,8 @@
 
   /// Add a suggestion for a [keyword]. The [offset] is the offset from the
   /// beginning of the keyword where the cursor will be left.
-  void suggestKeyword(String keyword, {int offset}) {
-    DartType elementType;
+  void suggestKeyword(String keyword, {int? offset}) {
+    DartType? elementType;
     if (keyword == 'null') {
       elementType = request.featureComputer.typeProvider.nullType;
     } else if (keyword == 'false' || keyword == 'true') {
@@ -506,10 +501,10 @@
 
   /// Add a suggestion for a [label].
   void suggestLabel(Label label) {
-    var completion = label.label?.name;
+    var completion = label.label.name;
     // TODO(brianwilkerson) Figure out why we're excluding labels consisting of
     //  a single underscore.
-    if (completion != null && completion.isNotEmpty && completion != '_') {
+    if (completion.isNotEmpty && completion != '_') {
       var suggestion = CompletionSuggestion(CompletionSuggestionKind.IDENTIFIER,
           Relevance.label, completion, completion.length, 0, false, false);
       suggestion.element = createLocalElement(
@@ -558,7 +553,7 @@
   /// used as the kind for the suggestion. The [inheritanceDistance] is the
   /// value of the inheritance distance feature computed for the method.
   void suggestMethod(MethodElement method,
-      {CompletionSuggestionKind kind, @required double inheritanceDistance}) {
+      {CompletionSuggestionKind? kind, required double inheritanceDistance}) {
     // TODO(brianwilkerson) Refactor callers so that we're passing in the type
     //  of the target (assuming we don't already have that type available via
     //  the [request]) and compute the [inheritanceDistance] in this method.
@@ -590,8 +585,10 @@
     var suggestion =
         _createSuggestion(method, kind: kind, relevance: relevance);
     if (suggestion != null) {
+      var enclosingElement = method.enclosingElement;
       if (method.name == 'setState' &&
-          flutter.isExactState(method.enclosingElement)) {
+          enclosingElement is ClassElement &&
+          flutter.isExactState(enclosingElement)) {
         // TODO(brianwilkerson) Make this more efficient by creating the correct
         //  suggestion in the first place.
         // Find the line indentation.
@@ -632,12 +629,13 @@
   /// [appendComma] is `true` then a comma will be included at the end of the
   /// completion text.
   void suggestNamedArgument(ParameterElement parameter,
-      {@required bool appendColon,
-      @required bool appendComma,
-      int replacementLength}) {
+      {required bool appendColon,
+      required bool appendComma,
+      int? replacementLength}) {
     var name = parameter.name;
-    var type = parameter.type?.getDisplayString(
-        withNullability: request.libraryElement.isNonNullableByDefault);
+    var type = parameter.type.getDisplayString(
+        withNullability:
+            request.libraryElement?.isNonNullableByDefault ?? false);
 
     var completion = name;
     if (appendColon) {
@@ -658,8 +656,9 @@
         if (defaultValue != null && defaultValue.text == '[]') {
           var completionLength = completion.length;
           completion += defaultValue.text;
-          if (defaultValue.cursorPosition != null) {
-            selectionOffset = completionLength + defaultValue.cursorPosition;
+          var cursorPosition = defaultValue.cursorPosition;
+          if (cursorPosition != null) {
+            selectionOffset = completionLength + cursorPosition;
           }
         }
       }
@@ -701,7 +700,7 @@
       ExecutableElement element, bool invokeSuper) async {
     var displayTextBuffer = StringBuffer();
     var builder = ChangeBuilder(session: request.result.session);
-    await builder.addDartFileEdit(request.result.path, (builder) {
+    await builder.addDartFileEdit(request.result.path!, (builder) {
       builder.addReplacement(range.node(targetId), (builder) {
         builder.writeOverride(
           element,
@@ -791,7 +790,7 @@
   /// referenced using a prefix, then the [prefix] should be provided.
   void suggestTopLevelFunction(FunctionElement function,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
-      String prefix}) {
+      String? prefix}) {
     var relevance =
         _computeTopLevelRelevance(function, elementType: function.returnType);
     _add(_createSuggestion(function,
@@ -804,7 +803,7 @@
   /// provided.
   void suggestTopLevelPropertyAccessor(PropertyAccessorElement accessor,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
-      String prefix}) {
+      String? prefix}) {
     assert(
         accessor.enclosingElement is CompilationUnitElement,
         'Enclosing element of ${accessor.runtimeType} is '
@@ -849,7 +848,7 @@
   /// referenced using a prefix, then the [prefix] should be provided.
   void suggestTopLevelVariable(TopLevelVariableElement variable,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
-      String prefix}) {
+      String? prefix}) {
     assert(variable.enclosingElement is CompilationUnitElement);
     var relevance =
         _computeTopLevelRelevance(variable, elementType: variable.type);
@@ -862,7 +861,7 @@
   /// referenced using a prefix, then the [prefix] should be provided.
   void suggestTypeAlias(TypeAliasElement typeAlias,
       {CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
-      String prefix}) {
+      String? prefix}) {
     var relevance = _computeTopLevelRelevance(typeAlias,
         elementType: _instantiateTypeAlias(typeAlias));
     _add(_createSuggestion(typeAlias,
@@ -893,7 +892,7 @@
 
   /// Add the given [suggestion] if it isn't `null` and if it isn't shadowed by
   /// a previously added suggestion.
-  void _add(protocol.CompletionSuggestion suggestion) {
+  void _add(protocol.CompletionSuggestion? suggestion) {
     if (suggestion != null) {
       var key = suggestion.completion;
       if (suggestion.element?.kind == protocol.ElementKind.CONSTRUCTOR) {
@@ -910,14 +909,14 @@
 
   /// Compute the value of the _element kind_ feature for the given [element] in
   /// the completion context.
-  double _computeElementKind(Element element, {double distance}) {
+  double _computeElementKind(Element element, {double? distance}) {
     var location = request.opType.completionLocation;
     var elementKind = request.featureComputer
         .elementKindFeature(element, location, distance: distance);
     if (elementKind < 0.0) {
       if (location == null) {
         listener?.missingCompletionLocationAt(
-            request.target.containingNode, request.target.entity);
+            request.target.containingNode, request.target.entity!);
       } else {
         listener?.missingElementKindTableFor(location);
       }
@@ -967,7 +966,7 @@
 
   /// Return the relevance score for a top-level [element].
   int _computeTopLevelRelevance(Element element,
-      {@required DartType elementType}) {
+      {required DartType elementType}) {
     // TODO(brianwilkerson) The old relevance computation used a signal based
     //  on whether the element being suggested was from the same library in
     //  which completion is being performed. Explore whether that's a useful
@@ -995,18 +994,18 @@
   /// than the kind normally used for the element. If a [prefix] is provided,
   /// then the element name (or completion) will be prefixed. The [relevance] is
   /// the relevance of the suggestion.
-  CompletionSuggestion _createSuggestion(Element element,
-      {String completion,
-      protocol.ElementKind elementKind,
-      CompletionSuggestionKind kind,
-      String prefix,
-      @required int relevance}) {
+  CompletionSuggestion? _createSuggestion(Element element,
+      {String? completion,
+      protocol.ElementKind? elementKind,
+      CompletionSuggestionKind? kind,
+      String? prefix,
+      required int relevance}) {
     if (element is ExecutableElement && element.isOperator) {
       // Do not include operators in suggestions
       return null;
     }
     completion ??= element.displayName;
-    if (completion == null || completion.isEmpty) {
+    if (completion.isEmpty) {
       return null;
     }
     if (prefix != null && prefix.isNotEmpty) {
@@ -1018,9 +1017,10 @@
 
     _setDocumentation(suggestion, element);
 
-    suggestion.element = protocol.convertElement(element);
+    var suggestedElement =
+        suggestion.element = protocol.convertElement(element);
     if (elementKind != null) {
-      suggestion.element.kind = elementKind;
+      suggestedElement.kind = elementKind;
     }
     var enclosingElement = element.enclosingElement;
     if (enclosingElement is ClassElement) {
@@ -1034,11 +1034,9 @@
       suggestion.parameterTypes =
           element.parameters.map((ParameterElement parameter) {
         var paramType = parameter.type;
-        // Gracefully degrade if type not resolved yet
-        return paramType != null
-            ? paramType.getDisplayString(
-                withNullability: request.libraryElement.isNonNullableByDefault)
-            : 'var';
+        return paramType.getDisplayString(
+            withNullability:
+                request.libraryElement?.isNonNullableByDefault ?? false);
       }).toList();
 
       var requiredParameters = element.parameters
@@ -1057,7 +1055,7 @@
 
   /// Return the type associated with the [accessor], maybe `null` if an
   /// invalid setter with no parameters at all.
-  DartType _getPropertyAccessorType(PropertyAccessorElement accessor) {
+  DartType? _getPropertyAccessorType(PropertyAccessorElement accessor) {
     if (accessor.isGetter) {
       return accessor.returnType;
     } else {
@@ -1074,7 +1072,7 @@
     var typeParameters = element.typeParameters;
     var typeArguments = const <DartType>[];
     if (typeParameters.isNotEmpty) {
-      var neverType = request.libraryElement.typeProvider.neverType;
+      var neverType = request.libraryElement!.typeProvider.neverType;
       typeArguments = List.filled(typeParameters.length, neverType);
     }
 
@@ -1092,7 +1090,7 @@
     var typeParameters = element.typeParameters;
     var typeArguments = const <DartType>[];
     if (typeParameters.isNotEmpty) {
-      var neverType = request.libraryElement.typeProvider.neverType;
+      var neverType = request.libraryElement!.typeProvider.neverType;
       typeArguments = List.filled(typeParameters.length, neverType);
     }
 
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
index 19510c7..6b96dcf 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.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:collection';
 
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -22,13 +20,6 @@
   @override
   Future<void> computeSuggestions(
       DartCompletionRequest request, SuggestionBuilder builder) async {
-    var containingLibrary = request.libraryElement;
-    // Gracefully degrade if the library could not be determined, such as with a
-    // detached part file or source change.
-    if (containingLibrary == null) {
-      return;
-    }
-
     // Recompute the target because resolution might have changed it.
     var expression = request.dotTarget;
     if (expression == null ||
@@ -73,13 +64,13 @@
         }
       }
     }
-    List<InterfaceType> mixins;
-    List<InterfaceType> superclassConstraints;
+    List<InterfaceType>? mixins;
+    List<InterfaceType>? superclassConstraints;
     if (expression is SuperExpression && type is InterfaceType) {
       // Suggest members from superclass if target is "super".
-      mixins = (type as InterfaceType).mixins;
-      superclassConstraints = (type as InterfaceType).superclassConstraints;
-      type = (type as InterfaceType).superclass;
+      mixins = type.mixins;
+      superclassConstraints = type.superclassConstraints;
+      type = type.superclass;
     }
     if (type is FunctionType) {
       builder.suggestFunctionCall();
@@ -106,7 +97,7 @@
 
   /// The best type for the found declaration, or `null` if no declaration found
   /// or failed to determine a type.
-  DartType typeFound;
+  DartType? typeFound;
 
   /// Construct a new instance to search for a declaration.
   _LocalBestTypeVisitor(this.targetName, int offset) : super(offset);
@@ -140,7 +131,10 @@
     if (declaration.name.name == targetName) {
       var typeName = declaration.returnType;
       if (typeName != null) {
-        typeFound = typeName.type;
+        var type = typeName.type;
+        if (type != null) {
+          typeFound = type;
+        }
       }
       finished();
     }
@@ -151,7 +145,10 @@
     if (declaration.name.name == targetName) {
       var typeName = declaration.returnType;
       if (typeName != null) {
-        typeFound = typeName.type;
+        var type = typeName.type;
+        if (type != null) {
+          typeFound = type;
+        }
       }
       finished();
     }
@@ -162,7 +159,10 @@
     if (declaration.name.name == targetName) {
       var typeName = declaration.functionType?.returnType;
       if (typeName != null) {
-        typeFound = typeName.type;
+        var type = typeName.type;
+        if (type != null) {
+          typeFound = type;
+        }
       }
       finished();
     }
@@ -177,7 +177,7 @@
   }
 
   @override
-  void declaredLocalVar(SimpleIdentifier name, TypeAnnotation type) {
+  void declaredLocalVar(SimpleIdentifier name, TypeAnnotation? type) {
     if (name.name == targetName) {
       var element = name.staticElement as VariableElement;
       typeFound = element.type;
@@ -190,14 +190,17 @@
     if (declaration.name.name == targetName) {
       var typeName = declaration.returnType;
       if (typeName != null) {
-        typeFound = typeName.type;
+        var type = typeName.type;
+        if (type != null) {
+          typeFound = type;
+        }
       }
       finished();
     }
   }
 
   @override
-  void declaredParam(SimpleIdentifier name, TypeAnnotation type) {
+  void declaredParam(SimpleIdentifier name, TypeAnnotation? type) {
     if (name.name == targetName) {
       // Type provided by the element in computeFull above.
       finished();
@@ -225,7 +228,8 @@
   /// If the 'dot' completion is a super expression, then [containingMethodName]
   /// is the name of the method in which the completion is requested.
   void buildSuggestions(InterfaceType type,
-      {List<InterfaceType> mixins, List<InterfaceType> superclassConstraints}) {
+      {List<InterfaceType>? mixins,
+      List<InterfaceType>? superclassConstraints}) {
     // Visit all of the types in the class hierarchy, collecting possible
     // completions.  If multiple elements are found that complete to the same
     // identifier, addSuggestion will discard all but the first (with a few
@@ -286,8 +290,9 @@
       // superclass, then the mixins.  This will ensure that they are visited
       // in the reverse order.
       typesToVisit.addAll(nextType.interfaces);
-      if (nextType.superclass != null) {
-        typesToVisit.add(nextType.superclass);
+      var superclass = nextType.superclass;
+      if (superclass != null) {
+        typesToVisit.add(superclass);
       }
       typesToVisit.addAll(nextType.superclassConstraints);
       typesToVisit.addAll(nextType.mixins);
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart
index 33dbf47..14fac8f 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.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:core';
 
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -56,7 +54,7 @@
             // Quoted empty string
             visitSimpleStringLiteral(uri);
           } else {
-            var data = request.sourceContents;
+            var data = request.sourceContents!;
             if (end == data.length) {
               var ch = data[end - 1];
               if (ch != '"' && ch != "'") {
@@ -68,7 +66,7 @@
           }
         }
       } else if (offset == start && offset == end) {
-        var data = request.sourceContents;
+        var data = request.sourceContents!;
         if (end == data.length) {
           var ch = data[end - 1];
           if (ch == '"' || ch == "'") {
@@ -102,7 +100,7 @@
   void _addDartSuggestions() {
     builder.suggestUri('dart:');
     var factory = request.sourceFactory;
-    for (var lib in factory.dartSdk.sdkLibraries) {
+    for (var lib in factory.dartSdk!.sdkLibraries) {
       if (!lib.isInternal && !lib.isImplementation) {
         if (!lib.shortName.startsWith('dart:_')) {
           builder.suggestUri(lib.shortName);
@@ -158,7 +156,7 @@
     if (dir is Folder) {
       try {
         for (var child in dir.getChildren()) {
-          String completion;
+          String? completion;
           if (child is Folder) {
             if (!child.shortName.startsWith('.')) {
               completion = '$uriPrefix${child.shortName}/';
@@ -215,7 +213,7 @@
     }
   }
 
-  String _extractPartialUri(SimpleStringLiteral node) {
+  String? _extractPartialUri(SimpleStringLiteral node) {
     if (request.offset < node.contentsOffset) {
       return null;
     }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
index 75b43b9..466fc48 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/utilities.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
-
 /// A collection of utility methods used by completion contributors.
 import 'package:analysis_server/src/protocol_server.dart'
     show CompletionSuggestion, Location;
@@ -17,7 +15,6 @@
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart' as protocol
     show Element, ElementKind;
-import 'package:meta/meta.dart';
 
 /// The name of the type `dynamic`;
 const DYNAMIC = 'dynamic';
@@ -54,23 +51,22 @@
     }
     offset = sb.length;
 
-    if (param.type is FunctionType) {
-      FunctionType type = param.type;
-
+    var parameterType = param.type;
+    if (parameterType is FunctionType) {
       var rangeStart = offset;
       int rangeLength;
 
       // todo (pq): consider adding ranges for params
       // pending: https://github.com/dart-lang/sdk/issues/40207
       // (types in closure param completions make this UX awkward)
-      final parametersString = buildClosureParameters(type);
+      final parametersString = buildClosureParameters(parameterType);
       final blockBuffer = StringBuffer(parametersString);
 
       blockBuffer.write(' ');
 
       // todo (pq): consider refactoring to share common logic w/
       //  ArgListContributor.buildClosureSuggestions
-      final returnType = type.returnType;
+      final returnType = parameterType.returnType;
       if (returnType.isVoid) {
         blockBuffer.write('{');
         rangeStart = sb.length + blockBuffer.length;
@@ -147,20 +143,13 @@
 /// Create a new protocol Element for inclusion in a completion suggestion.
 protocol.Element createLocalElement(
     Source source, protocol.ElementKind kind, SimpleIdentifier id,
-    {String parameters,
-    TypeAnnotation returnType,
+    {String? parameters,
+    TypeAnnotation? returnType,
     bool isAbstract = false,
     bool isDeprecated = false}) {
-  String name;
-  Location location;
-  if (id != null) {
-    name = id.name;
-    // TODO(danrubel) use lineInfo to determine startLine and startColumn
-    location = Location(source.fullName, id.offset, id.length, 0, 0, 0, 0);
-  } else {
-    name = '';
-    location = Location(source.fullName, -1, 0, 1, 0, 1, 0);
-  }
+  var name = id.name;
+  // TODO(danrubel) use lineInfo to determine startLine and startColumn
+  var location = Location(source.fullName, id.offset, id.length, 0, 0, 0, 0);
   var flags = protocol.Element.makeFlags(
       isAbstract: isAbstract,
       isDeprecated: isDeprecated,
@@ -172,34 +161,31 @@
 }
 
 /// Return a default argument value for the given [parameter].
-DefaultArgument getDefaultStringParameterValue(ParameterElement parameter,
-    {@required bool withNullability}) {
-  if (parameter != null) {
-    var type = parameter.type;
-    if (type is InterfaceType) {
-      if (type.isDartCoreList) {
-        return DefaultArgument('[]', cursorPosition: 1);
-      } else if (type.isDartCoreMap) {
-        return DefaultArgument('{}', cursorPosition: 1);
-      } else if (type.isDartCoreString) {
-        return DefaultArgument("''", cursorPosition: 1);
-      }
-    } else if (type is FunctionType) {
-      var params = type.parameters
-          .map((p) =>
-              '${getTypeString(p.type, withNullability: withNullability)}${p.name}')
-          .join(', ');
-      // TODO(devoncarew): Support having this method return text with newlines.
-      var text = '($params) {  }';
-      return DefaultArgument(text, cursorPosition: text.length - 2);
+DefaultArgument? getDefaultStringParameterValue(ParameterElement parameter,
+    {required bool withNullability}) {
+  var type = parameter.type;
+  if (type is InterfaceType) {
+    if (type.isDartCoreList) {
+      return DefaultArgument('[]', cursorPosition: 1);
+    } else if (type.isDartCoreMap) {
+      return DefaultArgument('{}', cursorPosition: 1);
+    } else if (type.isDartCoreString) {
+      return DefaultArgument("''", cursorPosition: 1);
     }
+  } else if (type is FunctionType) {
+    var params = type.parameters
+        .map((p) =>
+            '${getTypeString(p.type, withNullability: withNullability)}${p.name}')
+        .join(', ');
+    // TODO(devoncarew): Support having this method return text with newlines.
+    var text = '($params) {  }';
+    return DefaultArgument(text, cursorPosition: text.length - 2);
   }
-
   return null;
 }
 
 String getRequestLineIndent(DartCompletionRequest request) {
-  var content = request.result.content;
+  var content = request.result.content!;
   var lineStartOffset = request.offset;
   var notWhitespaceOffset = request.offset;
   for (; lineStartOffset > 0; lineStartOffset--) {
@@ -214,7 +200,7 @@
   return content.substring(lineStartOffset, notWhitespaceOffset);
 }
 
-String getTypeString(DartType type, {@required bool withNullability}) {
+String getTypeString(DartType type, {required bool withNullability}) {
   if (type.isDynamic) {
     return '';
   } else {
@@ -224,11 +210,7 @@
 
 /// Return name of the type of the given [identifier], or, if it unresolved, the
 /// name of its declared [declaredType].
-String nameForType(SimpleIdentifier identifier, TypeAnnotation declaredType) {
-  if (identifier == null) {
-    return null;
-  }
-
+String? nameForType(SimpleIdentifier identifier, TypeAnnotation? declaredType) {
   // Get the type from the identifier element.
   DartType type;
   var element = identifier.staticElement;
@@ -253,19 +235,12 @@
   }
 
   // If the type is unresolved, use the declared type.
-  if (type != null && type.isDynamic) {
+  if (type.isDynamic) {
     if (declaredType is TypeName) {
-      var id = declaredType.name;
-      if (id != null) {
-        return id.name;
-      }
+      return declaredType.name.name;
     }
     return DYNAMIC;
   }
-
-  if (type == null) {
-    return DYNAMIC;
-  }
   return type.getDisplayString(withNullability: false);
 }
 
@@ -276,7 +251,7 @@
 
   /// An optional location for the cursor, relative to the text's start. This
   /// field can be null.
-  final int cursorPosition;
+  final int? cursorPosition;
 
   DefaultArgument(this.text, {this.cursorPosition});
 }
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart
index 50e0fd16..e2b1b0b 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.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/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analysis_server/src/services/correction/name_suggestion.dart';
@@ -23,7 +21,7 @@
     if (opType.includeVarNameSuggestions) {
       // Resolution not needed for this completion.
 
-      var node = request.target.containingNode;
+      AstNode? node = request.target.containingNode;
       var offset = request.target.offset;
 
       // Use the refined node.
@@ -31,7 +29,7 @@
         node = CompletionTarget.findFormalParameter(node, offset);
       }
 
-      String strName;
+      String? strName;
       if (node is ExpressionStatement) {
         var expression = node.expression;
         if (expression is Identifier) {
@@ -83,13 +81,13 @@
   /// Given some [name], add a suggestion with the name (unless the name is
   /// `null` or empty).
   void _createNameSuggestion(SuggestionBuilder builder, String name) {
-    if (name != null && name.isNotEmpty) {
+    if (name.isNotEmpty) {
       builder.suggestName(name);
     }
   }
 
   /// Convert some [Identifier] to its [String] name.
-  String _getStringName(Identifier id) {
+  String? _getStringName(Identifier? id) {
     if (id == null) {
       return null;
     }
@@ -101,7 +99,7 @@
     return id.name;
   }
 
-  static Identifier _formalParameterTypeIdentifier(FormalParameter node) {
+  static Identifier? _formalParameterTypeIdentifier(FormalParameter node) {
     if (node is SimpleFormalParameter) {
       var type = node.type;
       if (type != null) {
@@ -112,7 +110,7 @@
     return null;
   }
 
-  static Identifier _typeAnnotationIdentifier(TypeAnnotation type) {
+  static Identifier? _typeAnnotationIdentifier(TypeAnnotation? type) {
     if (type is TypeName) {
       return type.name;
     }
diff --git a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
index 7a9229d..39ef023 100644
--- a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
@@ -12,6 +12,7 @@
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/generated/testing/token_factory.dart';
 import 'package:analyzer/src/generated/utilities_dart.dart';
+import 'package:meta/meta.dart';
 
 /// The class `AstTestFactory` defines utility methods that can be used to
 /// create AST nodes. The nodes that are created are complete in the sense that
@@ -26,6 +27,7 @@
 /// second is places where a shorter name seemed unambiguous and easier to read,
 /// such as using 'identifier' rather than 'prefixedIdentifier', or 'integer'
 /// rather than 'integerLiteral'.
+@internal
 class AstTestFactory {
   static AdjacentStringsImpl adjacentStrings(List<StringLiteral> strings) =>
       astFactory.adjacentStrings(strings);
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 11692c2..50db82b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -5912,10 +5912,26 @@
   @override
   void beginTypeVariable(Token token) {
     debugEvent("beginTypeVariable");
-    Identifier name = pop();
+    assert(checkState(token, [
+      unionOfKinds([ValueKinds.Identifier, ValueKinds.ParserRecovery]),
+      ValueKinds.AnnotationListOrNull,
+    ]));
+    Object name = pop();
     List<Expression> annotations = pop();
+    String typeVariableName;
+    int typeVariableCharOffset;
+    if (name is Identifier) {
+      typeVariableName = name.name;
+      typeVariableCharOffset = name.charOffset;
+    } else if (name is ParserRecovery) {
+      typeVariableName = null;
+      typeVariableCharOffset = name.charOffset;
+    } else {
+      return unhandled("${name.runtimeType}", "beginTypeVariable.name",
+          token.charOffset, uri);
+    }
     TypeVariableBuilder variable = new TypeVariableBuilder(
-        name.name, libraryBuilder, name.charOffset, uri);
+        typeVariableName, libraryBuilder, typeVariableCharOffset, uri);
     if (annotations != null) {
       inferAnnotations(variable.parameter, annotations);
       for (Expression annotation in annotations) {
diff --git a/pkg/front_end/lib/src/fasta/source/value_kinds.dart b/pkg/front_end/lib/src/fasta/source/value_kinds.dart
index 3fc36cc..1f59675 100644
--- a/pkg/front_end/lib/src/fasta/source/value_kinds.dart
+++ b/pkg/front_end/lib/src/fasta/source/value_kinds.dart
@@ -35,6 +35,8 @@
 import '../source/outline_builder.dart' as type;
 
 class ValueKinds {
+  static const ValueKind AnnotationListOrNull =
+      const SingleValueKind<List<type.Expression>>(NullValue.Metadata);
   static const ValueKind Arguments = const SingleValueKind<type.Arguments>();
   static const ValueKind ArgumentsOrNull =
       const SingleValueKind<type.Arguments>(NullValue.Arguments);
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart b/pkg/front_end/testcases/generic_metadata/issue45329.dart
new file mode 100644
index 0000000..bfd08bb
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart
@@ -0,0 +1,9 @@
+// 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.
+
+test() {
+  local<void Function()>() {}
+}
+
+main() {}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.strong.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.strong.expect
new file mode 100644
index 0000000..3dbf472
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.strong.expect
@@ -0,0 +1,16 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/generic_metadata/issue45329.dart:6:9: Error: Expected an identifier, but got 'void'.
+// Try inserting an identifier before 'void'.
+//   local<void Function()>() {}
+//         ^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test() → dynamic {
+  function local<#T1 extends core::Object? = dynamic>() → Null {}
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.strong.transformed.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.strong.transformed.expect
new file mode 100644
index 0000000..3dbf472
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.strong.transformed.expect
@@ -0,0 +1,16 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/generic_metadata/issue45329.dart:6:9: Error: Expected an identifier, but got 'void'.
+// Try inserting an identifier before 'void'.
+//   local<void Function()>() {}
+//         ^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test() → dynamic {
+  function local<#T1 extends core::Object? = dynamic>() → Null {}
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.textual_outline.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.textual_outline.expect
new file mode 100644
index 0000000..ec6b9e0
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.textual_outline.expect
@@ -0,0 +1,2 @@
+test() {}
+main() {}
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..f67dbb0
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.textual_outline_modelled.expect
@@ -0,0 +1,2 @@
+main() {}
+test() {}
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.expect
new file mode 100644
index 0000000..3dbf472
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.expect
@@ -0,0 +1,16 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/generic_metadata/issue45329.dart:6:9: Error: Expected an identifier, but got 'void'.
+// Try inserting an identifier before 'void'.
+//   local<void Function()>() {}
+//         ^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test() → dynamic {
+  function local<#T1 extends core::Object? = dynamic>() → Null {}
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.outline.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.outline.expect
new file mode 100644
index 0000000..64923de
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.outline.expect
@@ -0,0 +1,7 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+
+static method test() → dynamic
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.transformed.expect b/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.transformed.expect
new file mode 100644
index 0000000..3dbf472
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/issue45329.dart.weak.transformed.expect
@@ -0,0 +1,16 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/generic_metadata/issue45329.dart:6:9: Error: Expected an identifier, but got 'void'.
+// Try inserting an identifier before 'void'.
+//   local<void Function()>() {}
+//         ^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test() → dynamic {
+  function local<#T1 extends core::Object? = dynamic>() → Null {}
+}
+static method main() → dynamic {}
diff --git a/runtime/observatory/tests/service/service_kernel.status b/runtime/observatory/tests/service/service_kernel.status
index 291688c..a3f002c 100644
--- a/runtime/observatory/tests/service/service_kernel.status
+++ b/runtime/observatory/tests/service/service_kernel.status
@@ -15,17 +15,7 @@
 eval_internal_class_test: SkipByDesign # No incremental compiler available.
 eval_regression_flutter20255_test: SkipByDesign # No incremental compiler available.
 eval_test: SkipByDesign # No incremental compiler available.
-evaluate_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_async_closure_test: SkipByDesign # No incremental compiler available.
-evaluate_class_type_parameters_test: SkipByDesign # No incremental compiler available.
-evaluate_function_type_parameters_test: SkipByDesign # No incremental compiler available.
-evaluate_in_async_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_in_async_star_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_in_frame_rpc_test: SkipByDesign # No incremental compiler available.
-evaluate_in_frame_with_scope_test: SkipByDesign # No incremental compiler available.
-evaluate_in_sync_star_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_with_escaping_closure_test: SkipByDesign # No incremental compiler available.
-evaluate_with_scope_test: SkipByDesign # No incremental compiler available.
+evaluate_*: SkipByDesign # No incremental compiler available.
 get_allocation_traces_test: SkipByDesign # Allocation traces aren't consistent when running from snapshot.
 get_object_rpc_test: SkipByDesign # App-JIT snapshots don't contain script sources.
 pause_on_exceptions_test: SkipByDesign # No incremental compiler available.
@@ -172,7 +162,7 @@
 regress_28443_test: SkipByDesign # Debugger is disabled in AOT mode.
 regress_28980_test: SkipByDesign # Debugger is disabled in AOT mode.
 regress_34841_test: SkipByDesign # Debugger is disabled in AOT mode.
-reload_sources_test: SkipByDesign #  Hot reload is disabled in AOT mode.
+reload_sources_test: SkipByDesign # Hot reload is disabled in AOT mode.
 rewind_optimized_out_test: SkipByDesign # Debugger is disabled in AOT mode.
 rewind_test: SkipByDesign # Debugger is disabled in AOT mode.
 set_breakpoint_state_test: SkipByDesign # Debugger is disabled in AOT mode.
@@ -298,7 +288,7 @@
 evaluate_in_frame_with_scope_test: RuntimeError # Issue #34736
 evaluate_in_sync_star_activation_test: SkipByDesign # No incremental compiler available.
 evaluate_with_scope_test: RuntimeError # Issue #34736
-get_allocation_traces_test: SkipByDesign # Stack traces are different running from snapshot.
+get_allocation_traces_test: SkipByDesign # Allocation traces aren't consistent when running from snapshot.
 pause_on_exceptions_test: RuntimeError, Timeout # Issue #34736
 reload_sources_test: Skip # Times out.
 rewind_optimized_out_test: RuntimeError # Issue #34736
diff --git a/runtime/observatory_2/tests/service_2/service_2_kernel.status b/runtime/observatory_2/tests/service_2/service_2_kernel.status
index 717b43e..a3f002c 100644
--- a/runtime/observatory_2/tests/service_2/service_2_kernel.status
+++ b/runtime/observatory_2/tests/service_2/service_2_kernel.status
@@ -15,17 +15,7 @@
 eval_internal_class_test: SkipByDesign # No incremental compiler available.
 eval_regression_flutter20255_test: SkipByDesign # No incremental compiler available.
 eval_test: SkipByDesign # No incremental compiler available.
-evaluate_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_async_closure_test: SkipByDesign # No incremental compiler available.
-evaluate_class_type_parameters_test: SkipByDesign # No incremental compiler available.
-evaluate_function_type_parameters_test: SkipByDesign # No incremental compiler available.
-evaluate_in_async_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_in_async_star_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_in_frame_rpc_test: SkipByDesign # No incremental compiler available.
-evaluate_in_frame_with_scope_test: SkipByDesign # No incremental compiler available.
-evaluate_in_sync_star_activation_test: SkipByDesign # No incremental compiler available.
-evaluate_with_escaping_closure_test: SkipByDesign # No incremental compiler available.
-evaluate_with_scope_test: SkipByDesign # No incremental compiler available.
+evaluate_*: SkipByDesign # No incremental compiler available.
 get_allocation_traces_test: SkipByDesign # Allocation traces aren't consistent when running from snapshot.
 get_object_rpc_test: SkipByDesign # App-JIT snapshots don't contain script sources.
 pause_on_exceptions_test: SkipByDesign # No incremental compiler available.
@@ -161,6 +151,7 @@
 notify_debugger_on_exception_test: SkipByDesign # Debugger is disabled in AOT mode.
 parameters_in_scope_at_entry_test: SkipByDesign # Debugger is disabled in AOT mode.
 pause_idle_isolate_test: SkipByDesign # Debugger is disabled in AOT mode.
+pause_on_exception_from_slow_path_test: SkipByDesign # Debugger is disabled in AOT mode.
 pause_on_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
 pause_on_start_then_step_test: SkipByDesign # Debugger is disabled in AOT mode.
 pause_on_unhandled_async_exceptions2_test: SkipByDesign # Debugger is disabled in AOT mode.
diff --git a/tests/ffi/ffi.status b/tests/ffi/ffi.status
index f728d98..f157962 100644
--- a/tests/ffi/ffi.status
+++ b/tests/ffi/ffi.status
@@ -5,6 +5,9 @@
 [ $builder_tag == msan ]
 vmspecific_handle_test: Skip # https://dartbug.com/42314
 
+[ $mode == debug ]
+function_callbacks_structs_by_value_generated_test: Pass, Slow
+
 [ $system == android ]
 *: Pass, Slow # https://github.com/dart-lang/sdk/issues/38489
 
diff --git a/tests/ffi_2/ffi_2.status b/tests/ffi_2/ffi_2.status
index f728d98..f157962 100644
--- a/tests/ffi_2/ffi_2.status
+++ b/tests/ffi_2/ffi_2.status
@@ -5,6 +5,9 @@
 [ $builder_tag == msan ]
 vmspecific_handle_test: Skip # https://dartbug.com/42314
 
+[ $mode == debug ]
+function_callbacks_structs_by_value_generated_test: Pass, Slow
+
 [ $system == android ]
 *: Pass, Slow # https://github.com/dart-lang/sdk/issues/38489
 
diff --git a/tools/VERSION b/tools/VERSION
index 9472fdb..798da76 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 220
+PRERELEASE 221
 PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/lib/src/firestore.dart b/tools/bots/lib/src/firestore.dart
index 80b2315..c1d602a 100644
--- a/tools/bots/lib/src/firestore.dart
+++ b/tools/bots/lib/src/firestore.dart
@@ -41,12 +41,13 @@
       this._beginTransactionUrl, this._commitUrl);
 
   factory FirestoreDatabase(String project, String authToken) {
-    var databaseUrl = _apiUrl.resolve('projects/$project/databases/(default)/');
+    var databasePath = 'projects/$project/databases/(default)';
+    var databaseUrl = _apiUrl.resolve('$databasePath/');
     var documentsUrl = databaseUrl.resolve('documents/');
-    var queryUrl = databaseUrl.resolveUri(Uri(path: 'documents:runQuery'));
+    var queryUrl = _apiUrl.resolve('$databasePath/documents:runQuery');
     var beginTransactionUrl =
-        databaseUrl.resolveUri(Uri(path: 'documents:beginTransaction'));
-    var commitUrl = databaseUrl.resolveUri(Uri(path: 'documents:commit'));
+        _apiUrl.resolve('$databasePath/documents:beginTransaction');
+    var commitUrl = _apiUrl.resolve('$databasePath/documents:commit');
     var headers = {
       'Authorization': 'Bearer $authToken',
       'Accept': 'application/json',
@@ -56,7 +57,7 @@
         headers, documentsUrl, queryUrl, beginTransactionUrl, commitUrl);
   }
 
-  static final _apiUrl = Uri.https('firestore.googleapis.com', 'v1beta1/');
+  static final _apiUrl = Uri.https('firestore.googleapis.com', 'v1/');
 
   Future<List /*!*/ > runQuery(Query query) async {
     var body = jsonEncode(query.data);