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

Analyzer should hint on list assignment that is guaranteed to fail in checked mode #20610

Closed
stereotype441 opened this issue Aug 20, 2014 · 2 comments
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

The following code produces no errors, warnings, or hints in analyzer:

  class A {}
  class B extends A {}
  main() {
    List<B> listOfB = <A>[];
    print(listOfB);
  }

However, executing it in the VM (in checked mode) produces this error:

  type 'List<A>' is not a subtype of type 'List<B>' of 'listOfB'.

It seems like analyzer should produce a hint for this.

@bwilkerson
Copy link
Member

Removed Type-Defect, Priority-Unassigned labels.
Added Type-Enhancement, Priority-Medium, Analyzer-Hint labels.

@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 Aug 20, 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 exists in Strong Mode: https://dartpad.dartlang.org/704e735a6a77dc82fc0277c0679c36b6

error: Type check failed: is not of type List

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

4 participants