Lines 18-23
Link Here
|
18 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.Scope; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.Scope; |
|
|
21 |
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; |
21 |
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; |
22 |
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; |
22 |
|
23 |
|
23 |
/** |
24 |
/** |
Lines 175-185
Link Here
|
175 |
this.nullReferences[i] = null; |
176 |
this.nullReferences[i] = null; |
176 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
177 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
177 |
case FlowContext.IN_COMPARISON_NULL: |
178 |
case FlowContext.IN_COMPARISON_NULL: |
|
|
179 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
180 |
scope.problemReporter().localVariableNullReference(local, expression); |
181 |
continue; |
182 |
} |
178 |
if (!this.hideNullComparisonWarnings) { |
183 |
if (!this.hideNullComparisonWarnings) { |
179 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
184 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
180 |
} |
185 |
} |
181 |
continue; |
186 |
continue; |
182 |
case FlowContext.IN_COMPARISON_NON_NULL: |
187 |
case FlowContext.IN_COMPARISON_NON_NULL: |
|
|
188 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
189 |
scope.problemReporter().localVariableNullReference(local, expression); |
190 |
continue; |
191 |
} |
183 |
if (!this.hideNullComparisonWarnings) { |
192 |
if (!this.hideNullComparisonWarnings) { |
184 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
193 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
185 |
} |
194 |
} |
Lines 191-197
Link Here
|
191 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
200 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
192 |
continue; |
201 |
continue; |
193 |
} |
202 |
} |
194 |
} |
203 |
} else if (flowInfo.isPotentiallyNull(local)) { |
|
|
204 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
205 |
case FlowContext.IN_COMPARISON_NULL: |
206 |
this.nullReferences[i] = null; |
207 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
208 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
209 |
continue; |
210 |
} |
211 |
break; |
212 |
case FlowContext.IN_COMPARISON_NON_NULL: |
213 |
this.nullReferences[i] = null; |
214 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
215 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
216 |
continue; |
217 |
} |
218 |
break; |
219 |
} |
220 |
} |
195 |
break; |
221 |
break; |
196 |
case MAY_NULL: |
222 |
case MAY_NULL: |
197 |
if (flowInfo.isDefinitelyNull(local)) { |
223 |
if (flowInfo.isDefinitelyNull(local)) { |
Lines 238-248
Link Here
|
238 |
this.nullReferences[i] = null; |
264 |
this.nullReferences[i] = null; |
239 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
265 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
240 |
case FlowContext.IN_COMPARISON_NULL: |
266 |
case FlowContext.IN_COMPARISON_NULL: |
|
|
267 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
268 |
scope.problemReporter().localVariableNullReference(local, expression); |
269 |
continue; |
270 |
} |
241 |
if (!this.hideNullComparisonWarnings) { |
271 |
if (!this.hideNullComparisonWarnings) { |
242 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
272 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
243 |
} |
273 |
} |
244 |
continue; |
274 |
continue; |
245 |
case FlowContext.IN_COMPARISON_NON_NULL: |
275 |
case FlowContext.IN_COMPARISON_NON_NULL: |
|
|
276 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
277 |
scope.problemReporter().localVariableNullReference(local, expression); |
278 |
continue; |
279 |
} |
246 |
if (!this.hideNullComparisonWarnings) { |
280 |
if (!this.hideNullComparisonWarnings) { |
247 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
281 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
248 |
} |
282 |
} |
Lines 254-259
Link Here
|
254 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
288 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
255 |
continue; |
289 |
continue; |
256 |
} |
290 |
} |
|
|
291 |
} else if (flowInfo.isPotentiallyNull(local)) { |
292 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
293 |
case FlowContext.IN_COMPARISON_NULL: |
294 |
this.nullReferences[i] = null; |
295 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
296 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
297 |
continue; |
298 |
} |
299 |
break; |
300 |
case FlowContext.IN_COMPARISON_NON_NULL: |
301 |
this.nullReferences[i] = null; |
302 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
303 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
304 |
continue; |
305 |
} |
306 |
break; |
307 |
} |
257 |
} |
308 |
} |
258 |
break; |
309 |
break; |
259 |
case MAY_NULL: |
310 |
case MAY_NULL: |
Lines 467-478
Link Here
|
467 |
if (flowInfo.isDefinitelyNull(local)) { |
518 |
if (flowInfo.isDefinitelyNull(local)) { |
468 |
switch(checkType & CONTEXT_MASK) { |
519 |
switch(checkType & CONTEXT_MASK) { |
469 |
case FlowContext.IN_COMPARISON_NULL: |
520 |
case FlowContext.IN_COMPARISON_NULL: |
|
|
521 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
522 |
scope.problemReporter().localVariableNullReference(local, reference); |
523 |
return; |
524 |
} |
470 |
if (!this.hideNullComparisonWarnings) { |
525 |
if (!this.hideNullComparisonWarnings) { |
471 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
526 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
472 |
} |
527 |
} |
473 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
528 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
474 |
return; |
529 |
return; |
475 |
case FlowContext.IN_COMPARISON_NON_NULL: |
530 |
case FlowContext.IN_COMPARISON_NON_NULL: |
|
|
531 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
532 |
scope.problemReporter().localVariableNullReference(local, reference); |
533 |
return; |
534 |
} |
476 |
if (!this.hideNullComparisonWarnings) { |
535 |
if (!this.hideNullComparisonWarnings) { |
477 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
536 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
478 |
} |
537 |
} |
Lines 485-490
Link Here
|
485 |
scope.problemReporter().localVariableNullInstanceof(local, reference); |
544 |
scope.problemReporter().localVariableNullInstanceof(local, reference); |
486 |
return; |
545 |
return; |
487 |
} |
546 |
} |
|
|
547 |
} else if (flowInfo.isPotentiallyNull(local)) { |
548 |
switch(checkType & CONTEXT_MASK) { |
549 |
case FlowContext.IN_COMPARISON_NULL: |
550 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
551 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
552 |
return; |
553 |
} |
554 |
break; |
555 |
case FlowContext.IN_COMPARISON_NON_NULL: |
556 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
557 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
558 |
return; |
559 |
} |
560 |
break; |
561 |
} |
488 |
} |
562 |
} |
489 |
// if the contention is inside assert statement, we want to avoid null warnings only in case of |
563 |
// if the contention is inside assert statement, we want to avoid null warnings only in case of |
490 |
// comparisons and not in case of assignment and instanceof |
564 |
// comparisons and not in case of assignment and instanceof |