More changes to make dart2js dart 2 strong mode clean.

Change-Id: I796ac4b71ca9b91ec43ac72a02127ed87872f954
Reviewed-on: https://dart-review.googlesource.com/56460
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/inferrer/builder_kernel.dart b/pkg/compiler/lib/src/inferrer/builder_kernel.dart
index c995cfb..416db2d 100644
--- a/pkg/compiler/lib/src/inferrer/builder_kernel.dart
+++ b/pkg/compiler/lib/src/inferrer/builder_kernel.dart
@@ -48,12 +48,12 @@
   final GlobalTypeInferenceElementData<ir.Node> _memberData;
   final bool _inGenerativeConstructor;
 
-  LocalsHandler _locals;
+  LocalsHandler<ir.Node> _locals;
   final SideEffectsBuilder _sideEffectsBuilder;
-  final Map<JumpTarget, List<LocalsHandler>> _breaksFor =
-      <JumpTarget, List<LocalsHandler>>{};
-  final Map<JumpTarget, List<LocalsHandler>> _continuesFor =
-      <JumpTarget, List<LocalsHandler>>{};
+  final Map<JumpTarget, List<LocalsHandler<ir.Node>>> _breaksFor =
+      <JumpTarget, List<LocalsHandler<ir.Node>>>{};
+  final Map<JumpTarget, List<LocalsHandler<ir.Node>>> _continuesFor =
+      <JumpTarget, List<LocalsHandler<ir.Node>>>{};
   TypeInformation _returnType;
   final Set<Local> _capturedVariables = new Set<Local>();
 
@@ -90,7 +90,7 @@
 
     FieldInitializationScope<ir.Node> fieldScope =
         _inGenerativeConstructor ? new FieldInitializationScope(_types) : null;
-    _locals = new LocalsHandler(
+    _locals = new LocalsHandler<ir.Node>(
         _inferrer, _types, _options, _analyzedNode, fieldScope);
   }
 
@@ -522,7 +522,7 @@
       continueTargets.forEach(_clearBreaksAndContinues);
     } else {
       LocalsHandler saved = _locals;
-      List<LocalsHandler> localsToMerge = <LocalsHandler>[];
+      List<LocalsHandler<ir.Node>> localsToMerge = <LocalsHandler<ir.Node>>[];
       bool hasDefaultCase = false;
 
       for (ir.SwitchCase switchCase in node.cases) {
@@ -944,8 +944,12 @@
 
   void _setupBreaksAndContinues(JumpTarget target) {
     if (target == null) return;
-    if (target.isContinueTarget) _continuesFor[target] = <LocalsHandler>[];
-    if (target.isBreakTarget) _breaksFor[target] = <LocalsHandler>[];
+    if (target.isContinueTarget) {
+      _continuesFor[target] = <LocalsHandler<ir.Node>>[];
+    }
+    if (target.isBreakTarget) {
+      _breaksFor[target] = <LocalsHandler<ir.Node>>[];
+    }
   }
 
   void _clearBreaksAndContinues(JumpTarget element) {
@@ -953,15 +957,15 @@
     _breaksFor.remove(element);
   }
 
-  List<LocalsHandler> _getBreaks(JumpTarget target) {
-    List<LocalsHandler> list = <LocalsHandler>[_locals];
+  List<LocalsHandler<ir.Node>> _getBreaks(JumpTarget target) {
+    List<LocalsHandler<ir.Node>> list = <LocalsHandler<ir.Node>>[_locals];
     if (target == null) return list;
     if (!target.isBreakTarget) return list;
     return list..addAll(_breaksFor[target]);
   }
 
-  List<LocalsHandler> _getLoopBackEdges(JumpTarget target) {
-    List<LocalsHandler> list = <LocalsHandler>[_locals];
+  List<LocalsHandler<ir.Node>> _getLoopBackEdges(JumpTarget target) {
+    List<LocalsHandler<ir.Node>> list = <LocalsHandler<ir.Node>>[_locals];
     if (target == null) return list;
     if (!target.isContinueTarget) return list;
     return list..addAll(_continuesFor[target]);
@@ -1463,7 +1467,7 @@
     // We don't put the closure in the work queue of the
     // inferrer, because it will share information with its enclosing
     // method, like for example the types of local variables.
-    LocalsHandler closureLocals =
+    LocalsHandler<ir.Node> closureLocals =
         new LocalsHandler.from(_locals, node, useOtherTryBlock: false);
     KernelTypeGraphBuilder visitor = new KernelTypeGraphBuilder(
         _options,
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index 4ce047a..1f202ed 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -1102,7 +1102,7 @@
   }
 
   jsAst.Name _disambiguateGlobalMember(MemberEntity element) {
-    return _disambiguateGlobal(element, _proposeNameForMember);
+    return _disambiguateGlobal<MemberEntity>(element, _proposeNameForMember);
   }
 
   jsAst.Name _disambiguateGlobalType(Entity element) {
@@ -1112,8 +1112,8 @@
   /// Returns the disambiguated name for a top-level or static element.
   ///
   /// The resulting name is unique within the global-member namespace.
-  jsAst.Name _disambiguateGlobal(
-      Entity element, String proposeName(Entity element)) {
+  jsAst.Name _disambiguateGlobal<T extends Entity>(
+      T element, String proposeName(T element)) {
     // TODO(asgerf): We can reuse more short names if we disambiguate with
     // a separate namespace for each of the global holder objects.
     jsAst.Name newName = userGlobals[element];
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index 88f2c2d..905c3bd 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -616,7 +616,7 @@
     List<StaticMethod> statics = memberElements
         .where((e) => !e.isField)
         .cast<FunctionEntity>()
-        .map(_buildStaticMethod)
+        .map<StaticMethod>(_buildStaticMethod)
         .toList();
 
     if (library == _commonElements.interceptorsLibrary) {
diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart
index 35e75eb..7b4f019 100644
--- a/pkg/compiler/lib/src/source_file_provider.dart
+++ b/pkg/compiler/lib/src/source_file_provider.dart
@@ -144,7 +144,7 @@
 
   relativizeUri(Uri uri) => relativize(cwd, uri, isWindows);
 
-  SourceFile getUtf8SourceFile(Uri resourceUri) {
+  SourceFile<List<int>> getUtf8SourceFile(Uri resourceUri) {
     return utf8SourceFiles[resourceUri];
   }
 
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 1e94b01..6709e7e 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -2423,7 +2423,7 @@
   void generateThrowWithHelper(FunctionEntity helper, argument,
       {SourceInformation sourceInformation}) {
     js.Expression jsHelper = _emitter.staticFunctionAccess(helper);
-    List arguments = [];
+    List arguments = <js.Expression>[];
     if (argument is List) {
       argument.forEach((instruction) {
         use(instruction);
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index 04c906f..30764a9 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -1555,7 +1555,7 @@
   /// we have to register the instantiated type in the code generator. The
   /// [instructionType] of this node is not enough, because we also need the
   /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations].
-  List<DartType> instantiatedTypes;
+  List<InterfaceType> instantiatedTypes;
 
   /// If this node creates a closure class, [callMethod] is the call method of
   /// the closure class.
@@ -1759,7 +1759,7 @@
   /// contains the type(s) used in the (Dart) `New` expression(s). The
   /// [instructionType] of this node is not enough, because we also need the
   /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations].
-  List<DartType> instantiatedTypes;
+  List<InterfaceType> instantiatedTypes;
 
   /** The first input must be the target. */
   HInvokeStatic(this.element, inputs, AbstractValue type, this.typeArguments,
diff --git a/pkg/compiler/lib/src/ssa/variable_allocator.dart b/pkg/compiler/lib/src/ssa/variable_allocator.dart
index 7575c22..3bb3c85 100644
--- a/pkg/compiler/lib/src/ssa/variable_allocator.dart
+++ b/pkg/compiler/lib/src/ssa/variable_allocator.dart
@@ -550,9 +550,9 @@
     if (instruction is HCheck) {
       // Special case this instruction to use the name of its
       // input if it has one.
-      var temp = instruction;
+      HInstruction temp = instruction;
       do {
-        temp = temp.checkedInput;
+        temp = (temp as HCheck).checkedInput;
         name = names.ownName[temp];
       } while (name == null && temp is HCheck);
       if (name != null) return addAllocatedName(instruction, name);
diff --git a/pkg/compiler/lib/src/util/setlet.dart b/pkg/compiler/lib/src/util/setlet.dart
index 08195f0..62ccde0 100644
--- a/pkg/compiler/lib/src/util/setlet.dart
+++ b/pkg/compiler/lib/src/util/setlet.dart
@@ -138,7 +138,7 @@
         while (copyTo < CAPACITY) _contents[copyTo++] = null;
       } else {
         _contents = new Set<E>()
-          ..addAll(_contents)
+          ..addAll((_contents as List).cast<E>())
           ..add(element);
         _extra = _MARKER;
       }
diff --git a/pkg/js_ast/lib/src/builder.dart b/pkg/js_ast/lib/src/builder.dart
index 8366dd0..1de3981 100644
--- a/pkg/js_ast/lib/src/builder.dart
+++ b/pkg/js_ast/lib/src/builder.dart
@@ -1254,7 +1254,7 @@
 
   VariableDeclarationList finishVariableDeclarationList(
       Declaration firstVariable) {
-    var initialization = [];
+    var initialization = <VariableInitialization>[];
 
     void declare(Declaration declaration) {
       Expression initializer = null;