Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-01-21 21:29:21 +0000
committerStephan Herrmann2012-01-21 21:29:21 +0000
commit463c744a7c48c7701ee99d0b62d5b629d68c2912 (patch)
tree9ed0398761803da7bdc04519c01f7c86adef8c3e
parentbd0edd7688142c1743cb6b10766dfc576040f113 (diff)
downloadeclipse.jdt.core-463c744a7c48c7701ee99d0b62d5b629d68c2912.tar.gz
eclipse.jdt.core-463c744a7c48c7701ee99d0b62d5b629d68c2912.tar.xz
eclipse.jdt.core-463c744a7c48c7701ee99d0b62d5b629d68c2912.zip
include BinaryExpression of type String in the analysis.
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java37
1 files changed, 21 insertions, 16 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 6bae58eb91..7db916fe98 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -5141,10 +5141,10 @@ public void variableNullComparedToNonNull(VariableBinding variable, ASTNode loca
* @param checkForNull true if checking for null, false if checking for nonnull
*/
public boolean expressionNonNullComparison(Expression expr, boolean checkForNull) {
- int problemId;
- Binding binding;
- String[] arguments;
- int start, end;
+ int problemId = 0;
+ Binding binding = null;
+ String[] arguments = null;
+ int start = 0, end = 0;
Expression location = expr;
// unwrap uninteresting nodes:
@@ -5192,12 +5192,7 @@ public boolean expressionNonNullComparison(Expression expr, boolean checkForNull
|| expr instanceof ArrayInitializer
|| expr instanceof ClassLiteralAccess
|| expr instanceof ThisReference) {
- problemId = checkForNull
- ? IProblem.NonNullExpressionComparisonYieldsFalse
- : IProblem.RedundantNullCheckOnNonNullExpression;
- start = location.sourceStart;
- end = location.sourceEnd;
- arguments = NoArgument;
+ // fall through
} else if (expr instanceof Literal) {
if (expr instanceof NullLiteral) {
needImplementation(location); // reported as nonnull??
@@ -5207,12 +5202,13 @@ public boolean expressionNonNullComparison(Expression expr, boolean checkForNull
// false alarm, auto(un)boxing is involved
return false;
}
- problemId = checkForNull
- ? IProblem.NonNullExpressionComparisonYieldsFalse
- : IProblem.RedundantNullCheckOnNonNullExpression;
- start = location.sourceStart;
- end = location.sourceEnd;
- arguments = NoArgument;
+ // fall through
+ } else if (expr instanceof BinaryExpression) {
+ if ((expr.bits & ASTNode.ReturnTypeIDMASK) != TypeIds.T_JavaLangString) {
+ // false alarm, primitive types involved, must be auto(un)boxing?
+ return false;
+ }
+ // fall through
} else if (expr instanceof ConditionalExpression) {
needImplementation(location); // TODO
return false;
@@ -5220,6 +5216,15 @@ public boolean expressionNonNullComparison(Expression expr, boolean checkForNull
needImplementation(expr);
return false;
}
+ if (problemId == 0) {
+ // standard case, fill in details now
+ problemId = checkForNull
+ ? IProblem.NonNullExpressionComparisonYieldsFalse
+ : IProblem.RedundantNullCheckOnNonNullExpression;
+ start = location.sourceStart;
+ end = location.sourceEnd;
+ arguments = NoArgument;
+ }
this.handle(problemId, arguments, arguments, start, end);
return true;
}

Back to the top