Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle implicit future unions in downwards inference #25322

Closed
leafpetersen opened this issue Dec 30, 2015 · 2 comments

Comments

@leafpetersen
Copy link
Member

commented Dec 30, 2015

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
}
@jmesserly

This comment has been minimized.

Copy link
Contributor

commented Jul 21, 2016

@jmesserly

This comment has been minimized.

Copy link
Contributor

commented Aug 4, 2016

@jmesserly jmesserly closed this in 1c7aca0 Aug 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.