[js_ast] Fully migrated to 2.16

Change-Id: I3b216c529b6917f4a6ea1eb8e04c147c015d0f1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239601
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/js_ast/lib/src/characters.dart b/pkg/js_ast/lib/src/characters.dart
index aaa068d..5fd1196 100644
--- a/pkg/js_ast/lib/src/characters.dart
+++ b/pkg/js_ast/lib/src/characters.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.15
-
 library js_character_codes;
 
 const int $EOF = 0;
diff --git a/pkg/js_ast/test/deferred_expression_test.dart b/pkg/js_ast/test/deferred_expression_test.dart
index da1e158..f519964 100644
--- a/pkg/js_ast/test/deferred_expression_test.dart
+++ b/pkg/js_ast/test/deferred_expression_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.10
-
 import 'package:expect/expect.dart';
 import 'package:js_ast/js_ast.dart';
 
@@ -55,7 +53,7 @@
 void test(Map<Expression, DeferredExpression> map, String template,
     List<Expression> arguments, String expectedOutput) {
   Expression directExpression =
-      js.expressionTemplateFor(template).instantiate(arguments);
+      js.expressionTemplateFor(template).instantiate(arguments) as Expression;
   _Context directContext = _Context();
   Printer directPrinter =
       Printer(const JavaScriptPrintingOptions(), directContext);
@@ -64,7 +62,7 @@
 
   Expression deferredExpression = js
       .expressionTemplateFor(template)
-      .instantiate(arguments.map((e) => map[e]).toList());
+      .instantiate(arguments.map((e) => map[e]).toList()) as Expression;
   _Context deferredContext = _Context();
   Printer deferredPrinter =
       Printer(const JavaScriptPrintingOptions(), deferredContext);
@@ -72,7 +70,7 @@
   Expect.equals(expectedOutput, deferredContext.text);
 
   for (Expression argument in arguments) {
-    DeferredExpression deferred = map[argument];
+    DeferredExpression deferred = map[argument]!;
     Expect.isTrue(
         directContext.enterPositions.containsKey(argument),
         'Argument ${DebugPrint(argument)} not found in direct enter positions: '
@@ -144,7 +142,7 @@
 
   @override
   void exitNode(
-      Node node, int startPosition, int endPosition, int closingPosition) {
+      Node node, int startPosition, int endPosition, int? closingPosition) {
     exitPositions[node] =
         _Position(startPosition, endPosition, closingPosition);
     Expect.equals(enterPositions[node], startPosition);
@@ -161,7 +159,7 @@
 class _Position {
   final int startPosition;
   final int endPosition;
-  final int closingPosition;
+  final int? closingPosition;
 
   _Position(this.startPosition, this.endPosition, this.closingPosition);
 
diff --git a/pkg/js_ast/test/deferred_statement_test.dart b/pkg/js_ast/test/deferred_statement_test.dart
index 4db27a6..1ec6f13 100644
--- a/pkg/js_ast/test/deferred_statement_test.dart
+++ b/pkg/js_ast/test/deferred_statement_test.dart
@@ -2,16 +2,15 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.10
-
 import 'package:expect/expect.dart';
 import 'package:js_ast/js_ast.dart';
 
 class _DeferredStatement extends DeferredStatement {
+  final Statement? _statement;
   @override
-  final Statement statement;
+  Statement get statement => _statement!;
 
-  _DeferredStatement(this.statement);
+  _DeferredStatement(this._statement);
 }
 
 void main() {
@@ -38,14 +37,21 @@
 
   // Nested Blocks in DeferredStatements are elided.
   Expect.equals(
-      DebugPrint(Block([
-        _DeferredStatement(Block([
-          _DeferredStatement(Block.empty()),
-          Block.empty(),
-          Block([_DeferredStatement(Block.empty()), Block.empty()]),
-          _DeferredStatement(_DeferredStatement(Block.empty()))
-        ]))
-      ])),
+      DebugPrint(
+        Block([
+          _DeferredStatement(
+            Block([
+              _DeferredStatement(Block.empty()),
+              Block.empty(),
+              Block([
+                _DeferredStatement(Block.empty()),
+                Block.empty(),
+              ]),
+              _DeferredStatement(_DeferredStatement(Block.empty())),
+            ]),
+          ),
+        ]),
+      ),
       '{\n}\n');
 
   // DeferredStatement with empty Statement prints semicolon and a newline.
diff --git a/pkg/js_ast/test/printer_callback_test.dart b/pkg/js_ast/test/printer_callback_test.dart
index 433d3ad..45912bb 100644
--- a/pkg/js_ast/test/printer_callback_test.dart
+++ b/pkg/js_ast/test/printer_callback_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.10
-
 // Note: This test relies on LF line endings in the source file.
 
 // Test that JS printer callbacks occur when expected.
@@ -178,11 +176,8 @@
 
 void check(TestCase testCase) {
   Map<TestMode, String> map = testCase.data;
-  String code = map[TestMode.INPUT];
-
-  // Input is the same as output.
-  code ??= map[TestMode.NONE];
-
+  // Unspecified input is the same as output.
+  String? code = map[TestMode.INPUT] ?? map[TestMode.NONE]!;
   JavaScriptPrintingOptions options = JavaScriptPrintingOptions();
   Map arguments = {};
   testCase.environment.forEach((String name, String value) {
@@ -221,7 +216,7 @@
 
   @override
   void exitNode(
-      Node node, int startPosition, int endPosition, int delimiterPosition) {
+      Node node, int startPosition, int endPosition, int? delimiterPosition) {
     int value = id(node);
     if (mode == TestMode.DELIMITER && delimiterPosition != null) {
       tagMap.putIfAbsent(delimiterPosition, () => []).add(tag(value));
@@ -239,7 +234,7 @@
       if (offset < position) {
         sb.write(text.substring(offset, position));
       }
-      tagMap[position].forEach((String tag) => sb.write(tag));
+      tagMap[position]!.forEach((String tag) => sb.write(tag));
       offset = position;
     }
     if (offset < text.length) {
diff --git a/pkg/js_ast/test/string_escape_test.dart b/pkg/js_ast/test/string_escape_test.dart
index c483ba9..c61a3ff 100644
--- a/pkg/js_ast/test/string_escape_test.dart
+++ b/pkg/js_ast/test/string_escape_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.10
-
 library js_ast.string_escape_test;
 
 import 'package:js_ast/js_ast.dart';
@@ -14,9 +12,11 @@
 const int $RCURLY = $CLOSE_CURLY_BRACKET;
 
 void main() {
-  void check(input, expected, {bool utf8 = false}) {
-    if (input is List) input = String.fromCharCodes(input);
-    String actual = DebugPrint(js.string(input), utf8: utf8);
+  void check(Object input, Object expected, {bool utf8 = false}) {
+    String string = input is String
+        ? input
+        : String.fromCharCodes(List<int>.from(input as Iterable));
+    String actual = DebugPrint(js.string(string), utf8: utf8);
     if (expected is List) {
       expect(actual.codeUnits, expected);
     } else {