Merge pull request #1901 from dart-lang/dart-2-snapshot

Generate Dart 2 snapshots when running in Dart 2 mode
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/io.dart b/lib/src/io.dart
index edcfa47..43fe62d 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -959,7 +959,7 @@
 /// working directory.
 ///
 /// Returns a [ByteStream] that emits the contents of the archive.
-ByteStream createTarGz(List contents, {String baseDir}) {
+ByteStream createTarGz(List<String> contents, {String baseDir}) {
   return new ByteStream(StreamCompleter.fromFuture(new Future.sync(() async {
     var buffer = new StringBuffer();
     buffer.write('Creating .tar.gz stream containing:\n');
@@ -1018,7 +1018,8 @@
 
         // We need a newline at the end, otherwise the last file would get
         // ignored.
-        stdin = mtreeHeader + contents.join("\n") + "\n";
+        stdin =
+            mtreeHeader + contents.join("\n").replaceAll(' ', r'\040') + "\n";
       }
 
       // Setting the working directory should be unnecessary since we pass an
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) {