Merge pull request #94 from dart-lang/future
Changes to eliminate Future flattening in Dart 2.0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 47698f6..8804dc8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.15.2+14
+
+* Update code to eliminate Future flattening in Dart 2.0.
+
## 0.15.2+13
* Enforce ordering of Futures with `Future.microtask` rather than async and
diff --git a/lib/src/graph/package_graph.dart b/lib/src/graph/package_graph.dart
index 8eec163..376765c 100644
--- a/lib/src/graph/package_graph.dart
+++ b/lib/src/graph/package_graph.dart
@@ -127,7 +127,7 @@
///
/// If the asset cannot be found, returns null.
Future<AssetNode> getAssetNode(AssetId id) {
- return _inErrorZone<Future<AssetNode>>(() {
+ return _inErrorZone(() {
var cascade = _cascades[id.package];
if (cascade != null) return cascade.getAssetNode(id);
return new Future.value(null);
@@ -158,7 +158,7 @@
if (_status != NodeStatus.IDLE) {
// A build is still ongoing, so wait for it to complete and try again.
- return results.first.then<Future<AssetSet>>((_) => getAllAssets());
+ return results.first.then((_) => getAllAssets());
}
// If an unexpected error occurred, complete with that.
@@ -274,7 +274,7 @@
/// [Future]. If it throws a [BarbackException], that exception will be piped
/// to the returned [Future] as well. Any other exceptions will be piped to
/// [results].
- Future<T> _inErrorZone<T>(T body()) {
+ Future<T> _inErrorZone<T>(FutureOr<T> body()) {
var completer = new Completer<T>.sync();
runZoned(() {
new Future.sync(body)
diff --git a/lib/src/transformer/aggregate_transform.dart b/lib/src/transformer/aggregate_transform.dart
index 5c5fe6c..ce20d43 100644
--- a/lib/src/transformer/aggregate_transform.dart
+++ b/lib/src/transformer/aggregate_transform.dart
@@ -81,7 +81,7 @@
/// If an input with [id] cannot be found, throws an [AssetNotFoundException].
Future<String> readInputAsString(AssetId id, {Encoding encoding}) {
if (encoding == null) encoding = UTF8;
- return getInput(id).then<Future<String>>(
+ return getInput(id).then(
(input) => input.readAsString(encoding: encoding));
}
diff --git a/pubspec.yaml b/pubspec.yaml
index c1ed0ad..1d0e8a7 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -7,7 +7,7 @@
#
# When the minor or patch version of this is upgraded, you *must* update that
# version constraint in pub to stay in sync with this.
-version: 0.15.2+13
+version: 0.15.2+14
author: "Dart Team <misc@dartlang.org>"
homepage: http://github.com/dart-lang/barback