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

autocomplete not inferring loop variable in for..in loop #13710

Closed
jmesserly opened this issue Sep 30, 2013 · 9 comments
Closed

autocomplete not inferring loop variable in for..in loop #13710

jmesserly opened this issue Sep 30, 2013 · 9 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug

Comments

@jmesserly
Copy link

Code is like this:

void _transformFields(..., FieldDeclaration member, ...) {

  final fields = member.fields; // correctly inferred as VariableDeclarationList

// tooltip shows fields.variables is a NodeList<VariableDeclaration>
for (var field in fields.variables) {

  field. // only shows generic Object completions.

However, if I change my code to:

for (VariableDeclaration field in fields.variables) {

  now "field." gives completions

@jmesserly
Copy link
Author

Apologies that this bug is meta. I'm using "package:analyzer_experimental". So the analyzer is analyzing itself... :)

@jmesserly
Copy link
Author

additional info, chasing now the type hierarchy shows that NodeList does (eventually) implement Iterable<VariableDeclaration>:

    class NodeList<E extends ASTNode> extends ListWrapper<E> { ... }
    class ListWrapper<E> extends ListBase<E> implements List<E> { ... }
    typedef ListBase<E> = Object with ListMixin<E>;
    abstract class ListMixin<E> implements List<E> { ... }
    abstract class List<E> implements Iterable<E> { ... }

might be be something with generics?

@jmesserly
Copy link
Author

hmmm, here's another strange case:

  for (int i = 0; i < fields.variables.length; i++) {
    final field = fields.variables[i];
    final name = field.name.name;

field is inferred (black color) and has completions. field.name.name also works (hover shows "String get name"). But "name" is purple and doesn't complete.

@bwilkerson
Copy link
Member

Added this to the M8 milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@bwilkerson
Copy link
Member

Removed this from the M8 milestone.
Added this to the Later milestone.

@bwilkerson
Copy link
Member

Removed Type-Defect label.
Added Type-Enhancement label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@jmesserly jmesserly added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Aug 4, 2014
@jmesserly
Copy link
Author

assumed stale

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged 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. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants