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] unnecessary nullable #48679

Open
asashour opened this issue Mar 28, 2022 · 1 comment
Open

[analyzer] unnecessary nullable #48679

asashour opened this issue Mar 28, 2022 · 1 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. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@asashour
Copy link
Contributor

Would it be helpful to have a hint that a type can be not nullable?

For example: if a private method has a parameter, which is always called with a non nullable type, then it is triggered.

void main() {
  _test(1);
}

void a(int i) {
  _test(i);
}

void _test(int? x) { // <--- here
  print(x);
}
@vsmenon vsmenon added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Mar 28, 2022
@bwilkerson
Copy link
Member

Yes, it would be helpful. Unfortunately, this requires being able to look at every invocation of the function, and for most code we can't assume that every invocation is currently being analyzed.

About the only thing we could do at this point is to provide this analysis for private functions where we know that we can find all of the invocations of the function. While this would be possible to do, it isn't clear how much value it would add.

Internally there has been some discussion of whether and how we might provide whole-world / closed-world analyses, and this would be a candidate for such a framework, but there are no concrete plans to work on such support at the moment.

@srawlins srawlins added P3 A lower priority bug or feature request analyzer-warning Issues with the analyzer's Warning codes type-enhancement A request for a change that isn't a bug labels Apr 11, 2022
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. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants