Skip to content

Analyzer: no implicit cast errors for most downcasts to iterable #36267

Closed
@MichaelRFairhurst

Description

@MichaelRFairhurst
  Object o;                                                                      
  dynamic d;                                                                     
  for (var x in o) {} // no error                                                
  for (int x in d) {} // no error                                                
  for (int x in o) {} // error                                                   
  for (var x in d) {} // no error

The same behavior occurs for spread collections.

I would expect that all of these would be flagged based on the fact that all four of these assignments are flagged:

  Iterable<dynamic> idd = d;                                                     
  Iterable<int> iid = d;                                                         
  Iterable<dynamic> ido = o;                                                     
  Iterable<int> iio = o;

Metadata

Metadata

Assignees

Labels

P4dart-model-analyzer-specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions