Closed
Description
Various context in Dart essentially treat Future<T>
as an implicit union type Future<T> | T
. For example, await
allows either:
void test() async {
List<int> x = await [4];
List<int> y = await new Future.value([4]);
}
Downwards inference currently only considers the Future<int>
possibility here, and hence will infer type parameters for the Future
creation and the list literal in the second await
, but not for the list literal in the first await
. It would be useful to support both.
Other examples of this include the return value for the lambda argument to Future.then
, and values returned from async functions:
Future<List<int>> test() async {
return [4]; // Currently inferred
return new Future.value([4]); // Currently not inferred
}
Activity