Index: sdk/lib/io/io_sink.dart |
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart |
index f47b639a8c8729755154cd3500ad145676919f09..1dc624d9d30fa8b9fbbddae57d05cac1ac0ccb53 100644 |
--- a/sdk/lib/io/io_sink.dart |
+++ b/sdk/lib/io/io_sink.dart |
@@ -134,19 +134,16 @@ class _IOSinkImpl implements IOSink { |
} |
_isBound = true; |
// Wait for any sync operations to complete. |
- return _closeController().then((_) { |
+ Future targetAddStream() { |
return _target.addStream(stream) |
.whenComplete(() { |
_isBound = false; |
}); |
- }); |
- } |
- |
- Future _closeController() { |
- if (_controllerInstance == null) return new Future.immediate(null); |
+ } |
+ if (_controllerInstance == null) return targetAddStream(); |
var future = _controllerCompleter.future; |
_controllerInstance.close(); |
- return future; |
+ return future.then((_) => targetAddStream()); |
} |
Future close() { |