Skip to content

Incorrect "unnecessary cast" hint. #30897

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

Closed
leafpetersen opened this issue Sep 26, 2017 · 3 comments
Closed

Incorrect "unnecessary cast" hint. #30897

leafpetersen opened this issue Sep 26, 2017 · 3 comments
Assignees
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@leafpetersen
Copy link
Member

The following program produces an "unnecessary hint" cast from the analyzer.

void main() {
  Function(Null) f = (String x) => x;
  (f as Function(int))(3); 
}

The cast here is definitely necessary.

@leafpetersen
Copy link
Member Author

This showed up again, causing some confusion.

@bwilkerson bwilkerson added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jan 30, 2018
@leafpetersen
Copy link
Member Author

This popped up again fixing internal code with a slightly different repro:

class A {}

class B<T extends A> {
  void foo() {
    T Function(T) f;
    A Function(A) g;
    g = f as A Function(A);
  }
}

I suspect that the unnecessary cast code might be using Dart 1 subtyping.

cc @vsmenon @bwilkerson

@bwilkerson bwilkerson self-assigned this May 11, 2018
@bwilkerson
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants