Skip to content

Extend strong mode "impossible cast" warnings to explicit casts #29547

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

Open
leafpetersen opened this issue May 3, 2017 · 2 comments
Open

Extend strong mode "impossible cast" warnings to explicit casts #29547

leafpetersen opened this issue May 3, 2017 · 2 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-strong-mode-polish

Comments

@leafpetersen
Copy link
Member

Strong mode issues an error if a literal or an instance creation expression is implicitly cast to an incompatible type, since such a cast cannot possibly succeed in strong mode. We should consider issuing the same error on explicit casts .

void test() {
  int x = (true as int); // Make this an error
}

cc @Hixie @lrhn @floitschG @eernstg @munificent

@lrhn
Copy link
Member

lrhn commented Jun 25, 2018

Was this done or not?

In general, I think we could improve the experience around explicit casts.
For example [] as List<int> could infer the <int> (since interface instantiations are unique for a class, we known that it must be <int>).

@srawlins
Copy link
Member

This is definitely not done in analyzer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-strong-mode-polish
Projects
None yet
Development

No branches or pull requests

3 participants