-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
Describe the rule you'd like to see implemented
Related to https://www.reddit.com/r/dartlang/comments/s1if4e/dart_null_safety_vs_type_safety_dart_linter_in
There is currently no warning for when we are casting a value as non-nullable when that value could be nullable.
An example would be:
int? value = obj as int; // should probably be "as int?"While this cast is technically correct, casting as non-nullable instead of nullable brings no value and is instead a source of errror
Examples
This can happen in various situations:
void function(int? value) {...}
function(obj as int); // warn
int? a = obj as int; // warn
int? fn() {
return obj as int; // warn
}Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug