Merge pull request #65 from MichaelRFairhurst/fix-await-void

Fix places awaiting void, for dart 2.
diff --git a/.gitignore b/.gitignore
index 7a2e8dd..e50bf96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,11 @@
+# See https://www.dartlang.org/guides/libraries/private-files
+
 .buildlog
 .DS_Store
 .idea
-.pub/
+
+.dart_tool/
 .settings/
 build/
-packages
 pubspec.lock
 .packages
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08c8734..009aed7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.0.8
+
+* Deprecate `DelegatingFuture.typed`, it is not necessary in Dart 2.
+
 ## 2.0.7
 
 * Fix Dart 2 runtime errors.
diff --git a/lib/src/delegate/future.dart b/lib/src/delegate/future.dart
index 129ad49..62ff96f 100644
--- a/lib/src/delegate/future.dart
+++ b/lib/src/delegate/future.dart
@@ -4,8 +4,6 @@
 
 import 'dart:async';
 
-import '../typed/future.dart';
-
 /// A wrapper that forwards calls to a [Future].
 class DelegatingFuture<T> implements Future<T> {
   /// The wrapped [Future].
@@ -19,8 +17,9 @@
   /// This soundly converts a [Future] to a `Future<T>`, regardless of its
   /// original generic type, by asserting that its value is an instance of `T`
   /// whenever it's provided. If it's not, the future throws a [CastError].
+  @Deprecated('Use future.then((v) => v as T) instead.')
   static Future<T> typed<T>(Future future) =>
-      future is Future<T> ? future : new TypeSafeFuture<T>(future);
+      future is Future<T> ? future : future.then((v) => v as T);
 
   Stream<T> asStream() => _future.asStream();
 
diff --git a/lib/src/typed/future.dart b/lib/src/typed/future.dart
deleted file mode 100644
index 4630af7..0000000
--- a/lib/src/typed/future.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2016, 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.
-
-import 'dart:async';
-
-class TypeSafeFuture<T> implements Future<T> {
-  final Future _future;
-
-  TypeSafeFuture(this._future);
-
-  Stream<T> asStream() => _future.then((value) => value as T).asStream();
-
-  Future<T> catchError(Function onError, {bool test(Object error)}) async =>
-      new TypeSafeFuture<T>(_future.catchError(onError, test: test));
-
-  Future<S> then<S>(dynamic onValue(T value), {Function onError}) =>
-      _future.then((value) => onValue(value as T), onError: onError);
-
-  Future<T> whenComplete(action()) =>
-      new TypeSafeFuture<T>(_future.whenComplete(action));
-
-  Future<T> timeout(Duration timeLimit, {onTimeout()}) =>
-      new TypeSafeFuture<T>(_future.timeout(timeLimit, onTimeout: onTimeout));
-}
diff --git a/test/typed_wrapper/future_test.dart b/test/typed_wrapper/future_test.dart
deleted file mode 100644
index ea3303f..0000000
--- a/test/typed_wrapper/future_test.dart
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2016, 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.
-
-import 'dart:async';
-
-import "package:async/src/typed/future.dart";
-import "package:test/test.dart";
-
-import '../utils.dart';
-
-void main() {
-  group("with valid types, forwards", () {
-    TypeSafeFuture<int> wrapper;
-    TypeSafeFuture<int> errorWrapper;
-    setUp(() {
-      wrapper = new TypeSafeFuture<int>(new Future<Object>.value(12));
-
-      var error = new Future<Object>.error("oh no");
-      error.catchError((_) {}); // Don't let the error cause the test to fail.
-      errorWrapper = new TypeSafeFuture<int>(error);
-    });
-
-    test("asStream()", () {
-      expect(wrapper.asStream().toList(), completion(equals([12])));
-      expect(errorWrapper.asStream().first, throwsA("oh no"));
-    });
-
-    test("catchError()", () {
-      expect(
-          wrapper.catchError(expectAsync1((_) {}, count: 0),
-              test: expectAsync1((_) {}, count: 0)),
-          completion(equals(12)));
-
-      expect(
-          errorWrapper.catchError(expectAsync1((error) {
-            expect(error, equals("oh no"));
-            return 42;
-          }), test: expectAsync1((error) {
-            expect(error, equals("oh no"));
-            return true;
-          })),
-          completion(equals(42)));
-    });
-
-    test("then()", () {
-      expect(
-          wrapper.then((value) => value.toString()), completion(equals("12")));
-      expect(
-          errorWrapper.then(expectAsync1((_) {}, count: 0)), throwsA("oh no"));
-    });
-
-    test("whenComplete()", () {
-      expect(wrapper.whenComplete(expectAsync0(() {})), completion(equals(12)));
-      expect(errorWrapper.whenComplete(expectAsync0(() {})), throwsA("oh no"));
-    });
-
-    test("timeout()", () {
-      expect(wrapper.timeout(new Duration(seconds: 1)), completion(equals(12)));
-      expect(errorWrapper.timeout(new Duration(seconds: 1)), throwsA("oh no"));
-
-      expect(
-          new TypeSafeFuture<int>(new Completer<Object>().future)
-              .timeout(Duration.zero),
-          throwsA(new TypeMatcher<TimeoutException>()));
-
-      expect(
-          new TypeSafeFuture<int>(new Completer<Object>().future)
-              .timeout(Duration.zero, onTimeout: expectAsync0(() => 15)),
-          completion(equals(15)));
-    });
-  });
-
-  group("with invalid types", () {
-    TypeSafeFuture<int> wrapper;
-    setUp(() {
-      wrapper = new TypeSafeFuture<int>(new Future<Object>.value("foo"));
-    });
-
-    group("throws a CastError for", () {
-      test("asStream()", () {
-        expect(wrapper.asStream().first, throwsCastError);
-      });
-
-      test("then()", () {
-        expect(
-            wrapper.then(expectAsync1((_) {}, count: 0),
-                onError: expectAsync1((_) {}, count: 0)),
-            throwsCastError);
-      });
-
-      test("whenComplete()", () {
-        expect(wrapper.whenComplete(expectAsync0(() {})).then((_) {}),
-            throwsCastError);
-      });
-
-      test("timeout()", () {
-        expect(wrapper.timeout(new Duration(seconds: 3)).then((_) {}),
-            throwsCastError);
-
-        expect(
-            new TypeSafeFuture<int>(new Completer<Object>().future)
-                .timeout(Duration.zero, onTimeout: expectAsync0(() => "foo"))
-                .then((_) {}),
-            throwsCastError);
-      });
-    });
-  });
-}