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 1c2e60b1f1027fee689d0dc3521dc08c2c8bd8f1..54041506ec3e575ba6e33bc89e0e33a6cb74d08c 100644 |
--- a/pkg/analyzer/lib/src/generated/resolver.dart |
+++ b/pkg/analyzer/lib/src/generated/resolver.dart |
@@ -219,7 +219,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> { |
@override |
Object visitMethodInvocation(MethodInvocation node) { |
- _checkForCanBeNullAfterNullAware(node.realTarget); |
+ _checkForCanBeNullAfterNullAware(node.realTarget, node.operator); |
return super.visitMethodInvocation(node); |
} |
@@ -237,7 +237,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> { |
@override |
Object visitPropertyAccess(PropertyAccess node) { |
- _checkForCanBeNullAfterNullAware(node.realTarget); |
+ _checkForCanBeNullAfterNullAware(node.realTarget, node.operator); |
return super.visitPropertyAccess(node); |
} |
@@ -465,20 +465,23 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> { |
} |
/** |
- * Produce a hint if the given [expression] could have a value of `null`. |
+ * Produce a hint if the given [target] could have a value of `null`. |
*/ |
- void _checkForCanBeNullAfterNullAware(Expression expression) { |
- if (expression is ParenthesizedExpression) { |
- _checkForCanBeNullAfterNullAware(expression.expression); |
- } else if (expression is MethodInvocation) { |
- if (expression.operator?.type == TokenType.QUESTION_PERIOD) { |
+ void _checkForCanBeNullAfterNullAware(Expression target, Token operator) { |
+ if (operator?.type == TokenType.QUESTION_PERIOD) { |
Brian Wilkerson
2015/10/29 14:02:23
It seems strange to have to repeat this test for a
|
+ return; |
+ } |
+ if (target is ParenthesizedExpression) { |
+ _checkForCanBeNullAfterNullAware(target.expression, operator); |
+ } else if (target is MethodInvocation) { |
+ if (target.operator?.type == TokenType.QUESTION_PERIOD) { |
_errorReporter.reportErrorForNode( |
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, expression); |
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, target); |
} |
- } else if (expression is PropertyAccess) { |
- if (expression.operator.type == TokenType.QUESTION_PERIOD) { |
+ } else if (target is PropertyAccess) { |
+ if (target.operator.type == TokenType.QUESTION_PERIOD) { |
_errorReporter.reportErrorForNode( |
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, expression); |
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, target); |
} |
} |
} |