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

strong mode should allow type promotion from dynamic #25486

Closed
jmesserly opened this issue Jan 14, 2016 · 1 comment
Closed

strong mode should allow type promotion from dynamic #25486

jmesserly opened this issue Jan 14, 2016 · 1 comment
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

@jmesserly
Copy link

@leafpetersen found this example:

String from(value) {
  if (value is Iterable) {
    List<String> result = [];
    var items = value.map((x) => from(x)).toList();
    result.addAll(items);
  }
  return "";
}
// gives:
// [warning] items (dynamic) will need runtime check to cast to type Iterable<String> (scratch.dart, line 5, col 19)

If we change the definition of from to be String from(Object value) you'll get a better type for items (List<dynamic>)

@jmesserly jmesserly added type-enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Jan 14, 2016
@jmesserly jmesserly self-assigned this Jan 14, 2016
@jmesserly
Copy link
Author

https://codereview.chromium.org/1585323003/
hardest part of that CL was the fact that it invalidated one of my old tests :)

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed Priority-Medium labels Mar 1, 2016
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

2 participants