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

Add hint for incorrect assignment based on propagated types. #18864

Closed
stereotype441 opened this issue May 16, 2014 · 5 comments
Closed

Add hint for incorrect assignment based on propagated types. #18864

stereotype441 opened this issue May 16, 2014 · 5 comments
Assignees
Labels
analyzer-warning Issues with the analyzer's Warning codes 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

@stereotype441
Copy link
Member

This code:

  class A {}
  class B {}
  main() {
    Map<String, A> c = <String, A>{};
    c['foo'] = new B();
  }

produces the warning "A value of type 'B' cannot be assigned to a variable of type 'A'", as expected.

This code should produce the equivalent hint, but it doesn't:

  class A {}
  class B {}
  main() {
    var c = <String, A>{};
    c['foo'] = new B();
  }

@bwilkerson
Copy link
Member

Added this to the Later milestone.
Removed Type-Defect, Priority-Unassigned labels.
Added Type-Enhancement, Priority-Medium labels.

@kasperl
Copy link

kasperl commented Jul 10, 2014

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

@bwilkerson
Copy link
Member

Here is another concrete example:

main() {
  List<int> x = [0.5];
}

While the right-hand side has a static type of List<dynamic>, which is assignable to List<int>, it has a propagated type of List<double>, which isn't assignable.


Set owner to collinsn@google.com.
Removed Oldschool-Milestone-Later label.
Changed the title to: "Add hint for incorrect assignment based on propagated types.".

@DartBot
Copy link

DartBot commented Sep 26, 2014

This comment was originally written by collinsn@google.com


My internship is ending today.


Set owner to @bwilkerson.

@stereotype441 stereotype441 added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes labels Sep 26, 2014
@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 triaged labels Mar 1, 2016
@srawlins
Copy link
Member

This works with Strong Mode. https://dartpad.dartlang.org/2df2687e6c8032763f26d8af5e53b213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes 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

6 participants