Lines 269-274
Link Here
|
269 |
// ignore cases where field is used from within inside itself |
269 |
// ignore cases where field is used from within inside itself |
270 |
field.modifiers |= AccLocallyUsed; |
270 |
field.modifiers |= AccLocallyUsed; |
271 |
} |
271 |
} |
|
|
272 |
|
273 |
// if (field.hasRestrictedAccess()) { |
274 |
if ((field.modifiers & AccRestrictedAccess) != 0) { |
275 |
AccessRestriction restriction = scope.environment().getAccessRestriction(field.declaringClass); |
276 |
if (restriction != null) { |
277 |
scope.problemReporter().forbiddenReference(field, this, |
278 |
restriction.getFieldAccessMessageTemplate(), restriction.getProblemId()); |
279 |
} |
280 |
} |
272 |
|
281 |
|
273 |
if (!field.isViewedAsDeprecated()) return false; |
282 |
if (!field.isViewedAsDeprecated()) return false; |
274 |
|
283 |
|
Lines 288-307
Link Here
|
288 |
/* Answer true if the method use is considered deprecated. |
297 |
/* Answer true if the method use is considered deprecated. |
289 |
* An access in the same compilation unit is allowed. |
298 |
* An access in the same compilation unit is allowed. |
290 |
*/ |
299 |
*/ |
291 |
public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope) { |
300 |
public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, boolean isExplicitUse) { |
292 |
|
301 |
|
293 |
if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { |
302 |
if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { |
294 |
// ignore cases where method is used from within inside itself (e.g. direct recursions) |
303 |
// ignore cases where method is used from within inside itself (e.g. direct recursions) |
295 |
method.original().modifiers |= AccLocallyUsed; |
304 |
method.original().modifiers |= AccLocallyUsed; |
296 |
} |
305 |
} |
297 |
|
306 |
|
|
|
307 |
if (isExplicitUse && (method.modifiers & AccRestrictedAccess) != 0) { |
308 |
// note: explicit constructors calls warnings are kept despite the 'new C1()' case (two |
309 |
// warnings, one on type, the other on constructor), because of the 'super()' case. |
310 |
AccessRestriction restriction = scope.environment().getAccessRestriction(method.declaringClass); |
311 |
if (restriction != null) |
312 |
if (method.isConstructor()) |
313 |
scope.problemReporter().forbiddenReference(method, this, |
314 |
restriction.getConstructorAccessMessageTemplate(), restriction.getProblemId()); |
315 |
else |
316 |
scope.problemReporter().forbiddenReference(method, this, |
317 |
restriction.getMethodAccessMessageTemplate(), restriction.getProblemId()); |
318 |
} |
319 |
|
298 |
if (!method.isViewedAsDeprecated()) return false; |
320 |
if (!method.isViewedAsDeprecated()) return false; |
299 |
|
321 |
|
300 |
// inside same unit - no report |
322 |
// inside same unit - no report |
301 |
if (scope.isDefinedInSameUnit(method.declaringClass)) return false; |
323 |
if (scope.isDefinedInSameUnit(method.declaringClass)) return false; |
|
|
324 |
|
325 |
// if non explicit use, but explicitly deprecated still warn |
326 |
if (!isExplicitUse && (method.modifiers & AccDeprecated) == 0) return false; |
302 |
|
327 |
|
303 |
// if context is deprecated, may avoid reporting |
328 |
// if context is deprecated, may avoid reporting |
304 |
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; |
329 |
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; |
|
|
330 |
|
305 |
return true; |
331 |
return true; |
306 |
} |
332 |
} |
307 |
|
333 |
|
Lines 338-343
Link Here
|
338 |
scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId()); |
364 |
scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId()); |
339 |
} |
365 |
} |
340 |
} |
366 |
} |
|
|
367 |
if (refType instanceof SourceTypeBinding) |
368 |
((SourceTypeBinding) refType).checkDeprecatedAnnotation(); |
369 |
// WORK look force annotations resolution before deciding whether the type may be deprecated |
341 |
if (!refType.isViewedAsDeprecated()) return false; |
370 |
if (!refType.isViewedAsDeprecated()) return false; |
342 |
|
371 |
|
343 |
// inside same unit - no report |
372 |
// inside same unit - no report |