Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1427783003: Check for potential null operand in Not expressions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index b5d6e1dff9f4204d4916ee9166274bd60a6c6528..2d5fac3269d04c5bcd01af8a8d70c3c9d7b6a13e 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -665,6 +665,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
}
if (condition is BinaryExpression) {
_checkForPossibleNullConditionInBinaryExpression(condition);
+ } else if (condition is PrefixExpression) {
+ _checkForPossibleNullConditionInPrefixExpression(condition);
} else {
_checkForPossibleNullConditionInSimpleExpression(condition);
}
@@ -686,6 +688,17 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
}
/**
+ * Produce a hint if the operand of the given prefix [condition] could
+ * have a value of `null`.
+ */
+ void _checkForPossibleNullConditionInPrefixExpression(
+ PrefixExpression condition) {
+ if (condition.operator?.type == TokenType.BANG) {
+ _checkForPossibleNullCondition(condition.operand);
+ }
+ }
+
+ /**
* Produce a hint if the given [condition] could have a value of `null`.
*/
void _checkForPossibleNullConditionInSimpleExpression(Expression condition) {
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698