Lines 45-51
Link Here
|
45 |
VariableBinding finalVariables[]; |
45 |
VariableBinding finalVariables[]; |
46 |
int assignCount = 0; |
46 |
int assignCount = 0; |
47 |
|
47 |
|
48 |
LocalVariableBinding[] nullLocals; |
48 |
VariableBinding[] nullVariables; |
49 |
Expression[] nullReferences; |
49 |
Expression[] nullReferences; |
50 |
int[] nullCheckTypes; |
50 |
int[] nullCheckTypes; |
51 |
int nullCount; |
51 |
int nullCount; |
Lines 141-147
Link Here
|
141 |
if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) { |
141 |
if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) { |
142 |
// check only immutable null checks on innermost looping context |
142 |
// check only immutable null checks on innermost looping context |
143 |
for (int i = 0; i < this.nullCount; i++) { |
143 |
for (int i = 0; i < this.nullCount; i++) { |
144 |
LocalVariableBinding local = this.nullLocals[i]; |
144 |
VariableBinding local = this.nullVariables[i]; |
145 |
Expression expression = this.nullReferences[i]; |
145 |
Expression expression = this.nullReferences[i]; |
146 |
// final local variable |
146 |
// final local variable |
147 |
switch (this.nullCheckTypes[i]) { |
147 |
switch (this.nullCheckTypes[i]) { |
Lines 151-161
Link Here
|
151 |
this.nullReferences[i] = null; |
151 |
this.nullReferences[i] = null; |
152 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) { |
152 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) { |
153 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
153 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
154 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
154 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, expression); |
155 |
} |
155 |
} |
156 |
} else { |
156 |
} else { |
157 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
157 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
158 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
158 |
scope.problemReporter().variableNonNullComparedToNull(local, expression); |
159 |
} |
159 |
} |
160 |
} |
160 |
} |
161 |
continue; |
161 |
continue; |
Lines 167-177
Link Here
|
167 |
this.nullReferences[i] = null; |
167 |
this.nullReferences[i] = null; |
168 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
168 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
169 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
169 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
170 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
170 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, expression); |
171 |
} |
171 |
} |
172 |
} else { |
172 |
} else { |
173 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
173 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
174 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
174 |
scope.problemReporter().variableNonNullComparedToNull(local, expression); |
175 |
} |
175 |
} |
176 |
} |
176 |
} |
177 |
continue; |
177 |
continue; |
Lines 180-190
Link Here
|
180 |
this.nullReferences[i] = null; |
180 |
this.nullReferences[i] = null; |
181 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
181 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
182 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
182 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
183 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
183 |
scope.problemReporter().variableRedundantCheckOnNull(local, expression); |
184 |
} |
184 |
} |
185 |
} else { |
185 |
} else { |
186 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
186 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
187 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
187 |
scope.problemReporter().variableNullComparedToNonNull(local, expression); |
188 |
} |
188 |
} |
189 |
} |
189 |
} |
190 |
continue; |
190 |
continue; |
Lines 199-225
Link Here
|
199 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
199 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
200 |
case FlowContext.IN_COMPARISON_NULL: |
200 |
case FlowContext.IN_COMPARISON_NULL: |
201 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
201 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
202 |
scope.problemReporter().localVariableNullReference(local, expression); |
202 |
scope.problemReporter().variableNullReference(local, expression); |
203 |
continue; |
203 |
continue; |
204 |
} |
204 |
} |
205 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
205 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
206 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
206 |
scope.problemReporter().variableRedundantCheckOnNull(local, expression); |
207 |
} |
207 |
} |
208 |
continue; |
208 |
continue; |
209 |
case FlowContext.IN_COMPARISON_NON_NULL: |
209 |
case FlowContext.IN_COMPARISON_NON_NULL: |
210 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
210 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
211 |
scope.problemReporter().localVariableNullReference(local, expression); |
211 |
scope.problemReporter().variableNullReference(local, expression); |
212 |
continue; |
212 |
continue; |
213 |
} |
213 |
} |
214 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
214 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
215 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
215 |
scope.problemReporter().variableNullComparedToNonNull(local, expression); |
216 |
} |
216 |
} |
217 |
continue; |
217 |
continue; |
218 |
case FlowContext.IN_ASSIGNMENT: |
218 |
case FlowContext.IN_ASSIGNMENT: |
219 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
219 |
scope.problemReporter().variableRedundantNullAssignment(local, expression); |
220 |
continue; |
220 |
continue; |
221 |
case FlowContext.IN_INSTANCEOF: |
221 |
case FlowContext.IN_INSTANCEOF: |
222 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
222 |
scope.problemReporter().variableNullInstanceof(local, expression); |
223 |
continue; |
223 |
continue; |
224 |
} |
224 |
} |
225 |
} else if (flowInfo.isPotentiallyNull(local)) { |
225 |
} else if (flowInfo.isPotentiallyNull(local)) { |
Lines 227-240
Link Here
|
227 |
case FlowContext.IN_COMPARISON_NULL: |
227 |
case FlowContext.IN_COMPARISON_NULL: |
228 |
this.nullReferences[i] = null; |
228 |
this.nullReferences[i] = null; |
229 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
229 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
230 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
230 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
231 |
continue; |
231 |
continue; |
232 |
} |
232 |
} |
233 |
break; |
233 |
break; |
234 |
case FlowContext.IN_COMPARISON_NON_NULL: |
234 |
case FlowContext.IN_COMPARISON_NON_NULL: |
235 |
this.nullReferences[i] = null; |
235 |
this.nullReferences[i] = null; |
236 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
236 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
237 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
237 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
238 |
continue; |
238 |
continue; |
239 |
} |
239 |
} |
240 |
break; |
240 |
break; |
Lines 244-250
Link Here
|
244 |
case MAY_NULL: |
244 |
case MAY_NULL: |
245 |
if (flowInfo.isDefinitelyNull(local)) { |
245 |
if (flowInfo.isDefinitelyNull(local)) { |
246 |
this.nullReferences[i] = null; |
246 |
this.nullReferences[i] = null; |
247 |
scope.problemReporter().localVariableNullReference(local, expression); |
247 |
scope.problemReporter().variableNullReference(local, expression); |
248 |
continue; |
248 |
continue; |
249 |
} |
249 |
} |
250 |
break; |
250 |
break; |
Lines 263-269
Link Here
|
263 |
for (int i = 0; i < this.nullCount; i++) { |
263 |
for (int i = 0; i < this.nullCount; i++) { |
264 |
Expression expression = this.nullReferences[i]; |
264 |
Expression expression = this.nullReferences[i]; |
265 |
// final local variable |
265 |
// final local variable |
266 |
LocalVariableBinding local = this.nullLocals[i]; |
266 |
VariableBinding local = this.nullVariables[i]; |
267 |
switch (this.nullCheckTypes[i]) { |
267 |
switch (this.nullCheckTypes[i]) { |
268 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL: |
268 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL: |
269 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL: |
269 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL: |
Lines 271-281
Link Here
|
271 |
this.nullReferences[i] = null; |
271 |
this.nullReferences[i] = null; |
272 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
272 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
273 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
273 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
274 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
274 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, expression); |
275 |
} |
275 |
} |
276 |
} else { |
276 |
} else { |
277 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
277 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
278 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
278 |
scope.problemReporter().variableNonNullComparedToNull(local, expression); |
279 |
} |
279 |
} |
280 |
} |
280 |
} |
281 |
continue; |
281 |
continue; |
Lines 290-316
Link Here
|
290 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
290 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
291 |
case FlowContext.IN_COMPARISON_NULL: |
291 |
case FlowContext.IN_COMPARISON_NULL: |
292 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
292 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
293 |
scope.problemReporter().localVariableNullReference(local, expression); |
293 |
scope.problemReporter().variableNullReference(local, expression); |
294 |
continue; |
294 |
continue; |
295 |
} |
295 |
} |
296 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
296 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
297 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
297 |
scope.problemReporter().variableRedundantCheckOnNull(local, expression); |
298 |
} |
298 |
} |
299 |
continue; |
299 |
continue; |
300 |
case FlowContext.IN_COMPARISON_NON_NULL: |
300 |
case FlowContext.IN_COMPARISON_NON_NULL: |
301 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
301 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
302 |
scope.problemReporter().localVariableNullReference(local, expression); |
302 |
scope.problemReporter().variableNullReference(local, expression); |
303 |
continue; |
303 |
continue; |
304 |
} |
304 |
} |
305 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
305 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
306 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
306 |
scope.problemReporter().variableNullComparedToNonNull(local, expression); |
307 |
} |
307 |
} |
308 |
continue; |
308 |
continue; |
309 |
case FlowContext.IN_ASSIGNMENT: |
309 |
case FlowContext.IN_ASSIGNMENT: |
310 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
310 |
scope.problemReporter().variableRedundantNullAssignment(local, expression); |
311 |
continue; |
311 |
continue; |
312 |
case FlowContext.IN_INSTANCEOF: |
312 |
case FlowContext.IN_INSTANCEOF: |
313 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
313 |
scope.problemReporter().variableNullInstanceof(local, expression); |
314 |
continue; |
314 |
continue; |
315 |
} |
315 |
} |
316 |
} else if (flowInfo.isPotentiallyNull(local)) { |
316 |
} else if (flowInfo.isPotentiallyNull(local)) { |
Lines 318-331
Link Here
|
318 |
case FlowContext.IN_COMPARISON_NULL: |
318 |
case FlowContext.IN_COMPARISON_NULL: |
319 |
this.nullReferences[i] = null; |
319 |
this.nullReferences[i] = null; |
320 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
320 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
321 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
321 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
322 |
continue; |
322 |
continue; |
323 |
} |
323 |
} |
324 |
break; |
324 |
break; |
325 |
case FlowContext.IN_COMPARISON_NON_NULL: |
325 |
case FlowContext.IN_COMPARISON_NON_NULL: |
326 |
this.nullReferences[i] = null; |
326 |
this.nullReferences[i] = null; |
327 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
327 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
328 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
328 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
329 |
continue; |
329 |
continue; |
330 |
} |
330 |
} |
331 |
break; |
331 |
break; |
Lines 335-346
Link Here
|
335 |
case MAY_NULL: |
335 |
case MAY_NULL: |
336 |
if (flowInfo.isDefinitelyNull(local)) { |
336 |
if (flowInfo.isDefinitelyNull(local)) { |
337 |
this.nullReferences[i] = null; |
337 |
this.nullReferences[i] = null; |
338 |
scope.problemReporter().localVariableNullReference(local, expression); |
338 |
scope.problemReporter().variableNullReference(local, expression); |
339 |
continue; |
339 |
continue; |
340 |
} |
340 |
} |
341 |
if (flowInfo.isPotentiallyNull(local)) { |
341 |
if (flowInfo.isPotentiallyNull(local)) { |
342 |
this.nullReferences[i] = null; |
342 |
this.nullReferences[i] = null; |
343 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
343 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
344 |
continue; |
344 |
continue; |
345 |
} |
345 |
} |
346 |
break; |
346 |
break; |
Lines 472-498
Link Here
|
472 |
return true; |
472 |
return true; |
473 |
} |
473 |
} |
474 |
|
474 |
|
475 |
protected void recordNullReference(LocalVariableBinding local, |
475 |
protected void recordNullReference(VariableBinding local, |
476 |
Expression expression, int status) { |
476 |
Expression expression, int status) { |
477 |
if (this.nullCount == 0) { |
477 |
if (this.nullCount == 0) { |
478 |
this.nullLocals = new LocalVariableBinding[5]; |
478 |
this.nullVariables = new VariableBinding[5]; |
479 |
this.nullReferences = new Expression[5]; |
479 |
this.nullReferences = new Expression[5]; |
480 |
this.nullCheckTypes = new int[5]; |
480 |
this.nullCheckTypes = new int[5]; |
481 |
} |
481 |
} |
482 |
else if (this.nullCount == this.nullLocals.length) { |
482 |
else if (this.nullCount == this.nullVariables.length) { |
483 |
System.arraycopy(this.nullLocals, 0, |
483 |
System.arraycopy(this.nullVariables, 0, |
484 |
this.nullLocals = new LocalVariableBinding[this.nullCount * 2], 0, this.nullCount); |
484 |
this.nullVariables = new VariableBinding[this.nullCount * 2], 0, this.nullCount); |
485 |
System.arraycopy(this.nullReferences, 0, |
485 |
System.arraycopy(this.nullReferences, 0, |
486 |
this.nullReferences = new Expression[this.nullCount * 2], 0, this.nullCount); |
486 |
this.nullReferences = new Expression[this.nullCount * 2], 0, this.nullCount); |
487 |
System.arraycopy(this.nullCheckTypes, 0, |
487 |
System.arraycopy(this.nullCheckTypes, 0, |
488 |
this.nullCheckTypes = new int[this.nullCount * 2], 0, this.nullCount); |
488 |
this.nullCheckTypes = new int[this.nullCount * 2], 0, this.nullCount); |
489 |
} |
489 |
} |
490 |
this.nullLocals[this.nullCount] = local; |
490 |
this.nullVariables[this.nullCount] = local; |
491 |
this.nullReferences[this.nullCount] = expression; |
491 |
this.nullReferences[this.nullCount] = expression; |
492 |
this.nullCheckTypes[this.nullCount++] = status; |
492 |
this.nullCheckTypes[this.nullCount++] = status; |
493 |
} |
493 |
} |
494 |
|
494 |
|
495 |
public void recordUsingNullReference(Scope scope, LocalVariableBinding local, |
495 |
public void recordUsingNullReference(Scope scope, VariableBinding local, |
496 |
Expression reference, int checkType, FlowInfo flowInfo) { |
496 |
Expression reference, int checkType, FlowInfo flowInfo) { |
497 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0 || |
497 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0 || |
498 |
flowInfo.isDefinitelyUnknown(local)) { |
498 |
flowInfo.isDefinitelyUnknown(local)) { |
Lines 504-517
Link Here
|
504 |
if (flowInfo.isDefinitelyNonNull(local)) { |
504 |
if (flowInfo.isDefinitelyNonNull(local)) { |
505 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
505 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
506 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
506 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
507 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); |
507 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, reference); |
508 |
} |
508 |
} |
509 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
509 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
510 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
510 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
511 |
} |
511 |
} |
512 |
} else { |
512 |
} else { |
513 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
513 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
514 |
scope.problemReporter().localVariableNonNullComparedToNull(local, reference); |
514 |
scope.problemReporter().variableNonNullComparedToNull(local, reference); |
515 |
} |
515 |
} |
516 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
516 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
517 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
517 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
Lines 520-533
Link Here
|
520 |
} else if (flowInfo.isDefinitelyNull(local)) { |
520 |
} else if (flowInfo.isDefinitelyNull(local)) { |
521 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
521 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
522 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
522 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
523 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
523 |
scope.problemReporter().variableRedundantCheckOnNull(local, reference); |
524 |
} |
524 |
} |
525 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
525 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
526 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
526 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
527 |
} |
527 |
} |
528 |
} else { |
528 |
} else { |
529 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
529 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
530 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
530 |
scope.problemReporter().variableNullComparedToNonNull(local, reference); |
531 |
} |
531 |
} |
532 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
532 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
533 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
533 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
Lines 571-581
Link Here
|
571 |
switch(checkType & CONTEXT_MASK) { |
571 |
switch(checkType & CONTEXT_MASK) { |
572 |
case FlowContext.IN_COMPARISON_NULL: |
572 |
case FlowContext.IN_COMPARISON_NULL: |
573 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
573 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
574 |
scope.problemReporter().localVariableNullReference(local, reference); |
574 |
scope.problemReporter().variableNullReference(local, reference); |
575 |
return; |
575 |
return; |
576 |
} |
576 |
} |
577 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
577 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
578 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
578 |
scope.problemReporter().variableRedundantCheckOnNull(local, reference); |
579 |
} |
579 |
} |
580 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
580 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
581 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
581 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
Lines 583-616
Link Here
|
583 |
return; |
583 |
return; |
584 |
case FlowContext.IN_COMPARISON_NON_NULL: |
584 |
case FlowContext.IN_COMPARISON_NON_NULL: |
585 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
585 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
586 |
scope.problemReporter().localVariableNullReference(local, reference); |
586 |
scope.problemReporter().variableNullReference(local, reference); |
587 |
return; |
587 |
return; |
588 |
} |
588 |
} |
589 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
589 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
590 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
590 |
scope.problemReporter().variableNullComparedToNonNull(local, reference); |
591 |
} |
591 |
} |
592 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
592 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
593 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
593 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
594 |
} |
594 |
} |
595 |
return; |
595 |
return; |
596 |
case FlowContext.IN_ASSIGNMENT: |
596 |
case FlowContext.IN_ASSIGNMENT: |
597 |
scope.problemReporter().localVariableRedundantNullAssignment(local, reference); |
597 |
scope.problemReporter().variableRedundantNullAssignment(local, reference); |
598 |
return; |
598 |
return; |
599 |
case FlowContext.IN_INSTANCEOF: |
599 |
case FlowContext.IN_INSTANCEOF: |
600 |
scope.problemReporter().localVariableNullInstanceof(local, reference); |
600 |
scope.problemReporter().variableNullInstanceof(local, reference); |
601 |
return; |
601 |
return; |
602 |
} |
602 |
} |
603 |
} else if (flowInfo.isPotentiallyNull(local)) { |
603 |
} else if (flowInfo.isPotentiallyNull(local)) { |
604 |
switch(checkType & CONTEXT_MASK) { |
604 |
switch(checkType & CONTEXT_MASK) { |
605 |
case FlowContext.IN_COMPARISON_NULL: |
605 |
case FlowContext.IN_COMPARISON_NULL: |
606 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
606 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
607 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
607 |
scope.problemReporter().variablePotentialNullReference(local, reference); |
608 |
return; |
608 |
return; |
609 |
} |
609 |
} |
610 |
break; |
610 |
break; |
611 |
case FlowContext.IN_COMPARISON_NON_NULL: |
611 |
case FlowContext.IN_COMPARISON_NON_NULL: |
612 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
612 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
613 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
613 |
scope.problemReporter().variablePotentialNullReference(local, reference); |
614 |
return; |
614 |
return; |
615 |
} |
615 |
} |
616 |
break; |
616 |
break; |
Lines 629-639
Link Here
|
629 |
return; |
629 |
return; |
630 |
} |
630 |
} |
631 |
if (flowInfo.isDefinitelyNull(local)) { |
631 |
if (flowInfo.isDefinitelyNull(local)) { |
632 |
scope.problemReporter().localVariableNullReference(local, reference); |
632 |
scope.problemReporter().variableNullReference(local, reference); |
633 |
return; |
633 |
return; |
634 |
} |
634 |
} |
635 |
if (flowInfo.isPotentiallyNull(local)) { |
635 |
if (flowInfo.isPotentiallyNull(local)) { |
636 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
636 |
scope.problemReporter().variablePotentialNullReference(local, reference); |
637 |
return; |
637 |
return; |
638 |
} |
638 |
} |
639 |
recordNullReference(local, reference, checkType); |
639 |
recordNullReference(local, reference, checkType); |