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

Why does strict-raw-types not apply to is or as? #60282

Open
mmcdon20 opened this issue Mar 8, 2025 · 0 comments
Open

Why does strict-raw-types not apply to is or as? #60282

mmcdon20 opened this issue Mar 8, 2025 · 0 comments
Labels
area-devexp Developer experience items (DevTools, IDEs, analysis server, completions, refactorings, ...).

Comments

@mmcdon20
Copy link

mmcdon20 commented Mar 8, 2025

Assuming analysis_options.yaml:

analyzer:
  language:
    strict-raw-types: true

Consider the following piece of code:

class Generic<T> {
  T value;
  Generic(this.value);
}

void main() {
  Object o = Generic(5);
  if (o is Generic) /* o is implicitly promoted to Generic<dynamic> */ {
    print(o.value);
  }
}

There is no warning for o is Generic even though Generic is in fact a raw type. I realize that this behavior is to spec, since the spec makes a specific exemption for is and as. But the exemption seems counter to the goal of the feature. If you actually want to promote o to Generic<dynamic> you can always write that explicitly if (o is Generic<dynamic>).

@mmcdon20 mmcdon20 added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Mar 8, 2025
@johnniwinther johnniwinther added the area-devexp Developer experience items (DevTools, IDEs, analysis server, completions, refactorings, ...). label Mar 10, 2025
@lrhn lrhn removed the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp Developer experience items (DevTools, IDEs, analysis server, completions, refactorings, ...).
Projects
None yet
Development

No branches or pull requests

3 participants