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
Closed

Handle implicit future unions in downwards inference #25322

leafpetersen opened this issue Dec 30, 2015 · 2 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@leafpetersen
Copy link
Member

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
}
@leafpetersen leafpetersen added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request analyzer-strong-mode labels Dec 30, 2015
@leafpetersen leafpetersen self-assigned this Dec 30, 2015
@munificent munificent mentioned this issue Feb 18, 2016
35 tasks
@leafpetersen leafpetersen removed their assignment Feb 24, 2016
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
@leafpetersen leafpetersen added P2 A bug or feature request we're likely to work on and removed P3 A lower priority bug or feature request labels Apr 7, 2016
@jmesserly jmesserly self-assigned this May 12, 2016
@jmesserly
Copy link

CC @trinarytree

@jmesserly
Copy link

Some progress on this in https://codereview.chromium.org/2208953002/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants