Fix Dart 2 runtime errors (#1902)

diff --git a/lib/src/command/deps.dart b/lib/src/command/deps.dart
index 99a6de5..262beaa 100644
--- a/lib/src/command/deps.dart
+++ b/lib/src/command/deps.dart
@@ -195,7 +195,7 @@
       var map = pair.last;
 
       if (visited.contains(package.name)) {
-        map[log.gray('${package.name}...')] = {};
+        map[log.gray('${package.name}...')] = <String, Map>{};
         continue;
       }
 
@@ -275,9 +275,10 @@
   /// Lists all Dart files in the `bin` directory of the [package].
   ///
   /// Returns file names without extensions.
-  List<String> _getExecutablesFor(Package package) => package.executablePaths
-      .where((e) => _isDartExecutable(p.absolute(package.dir, e)))
-      .map((e) => p.basenameWithoutExtension(e));
+  Iterable<String> _getExecutablesFor(Package package) =>
+      package.executablePaths
+          .where((e) => _isDartExecutable(p.absolute(package.dir, e)))
+          .map((e) => p.basenameWithoutExtension(e));
 
   /// Returns formatted string that lists [executables] for the [packageName].
   /// Examples:
diff --git a/lib/src/command/global_activate.dart b/lib/src/command/global_activate.dart
index 126d1c7..c6b89e4 100644
--- a/lib/src/command/global_activate.dart
+++ b/lib/src/command/global_activate.dart
@@ -67,7 +67,7 @@
     }
 
     var overwrite = argResults["overwrite"];
-    var args = argResults.rest;
+    Iterable<String> args = argResults.rest;
 
     readArg([String error]) {
       if (args.isEmpty) usageException(error);
diff --git a/lib/src/global_packages.dart b/lib/src/global_packages.dart
index f629176..c99f9f3 100644
--- a/lib/src/global_packages.dart
+++ b/lib/src/global_packages.dart
@@ -229,7 +229,7 @@
       // Try to avoid starting up an asset server to precompile packages if
       // possible. This is faster and produces better error messages.
       var package = entrypoint.packageGraph.packages[packageName];
-      var precompiled = {};
+      var precompiled = <String, String>{};
       await waitAndPrintErrors(package.executablePaths.map((path) async {
         var url = p.toUri(p.join(package.dir, path));
         var basename = p.basename(path);
diff --git a/lib/src/source/hosted.dart b/lib/src/source/hosted.dart
index a68f03d..e849554 100644
--- a/lib/src/source/hosted.dart
+++ b/lib/src/source/hosted.dart
@@ -145,7 +145,7 @@
     }
 
     var doc = jsonDecode(body);
-    return doc['versions'].map((map) {
+    return (doc['versions'] as List).map((map) {
       var pubspec = new Pubspec.fromMap(map['pubspec'], systemCache.sources,
           expectedName: ref.name, location: url);
       var id = source.idFor(ref.name, pubspec.version,
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 8787670..95a5d52 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -362,7 +362,7 @@
 ///
 /// Unlike [Stream.first], this is safe to use with single-subscription streams.
 Future<T> streamFirst<T>(Stream<T> stream) {
-  var completer = new Completer();
+  var completer = new Completer<T>();
   var subscription;
   subscription = stream.listen((value) {
     subscription.cancel();
diff --git a/test/descriptor_server.dart b/test/descriptor_server.dart
index 92b9066..af8d5fb 100644
--- a/test/descriptor_server.dart
+++ b/test/descriptor_server.dart
@@ -117,8 +117,8 @@
 /// value can be read successfully. If an error occurs before any values are
 /// emitted, the returned Future completes to that error.
 Future<Stream<T>> _validateStream<T>(Stream<T> stream) {
-  var completer = new Completer<Stream>();
-  var controller = new StreamController(sync: true);
+  var completer = new Completer<Stream<T>>();
+  var controller = new StreamController<T>(sync: true);
 
   StreamSubscription subscription;
   subscription = stream.listen((value) {