Lines 11-16
Link Here
|
11 |
package org.eclipse.jdt.internal.compiler.ast; |
11 |
package org.eclipse.jdt.internal.compiler.ast; |
12 |
|
12 |
|
13 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
13 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
|
|
14 |
import org.eclipse.jdt.internal.compiler.env.AccessRestriction; |
14 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
15 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
15 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
16 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
16 |
|
17 |
|
Lines 95-101
Link Here
|
95 |
} |
96 |
} |
96 |
this.binding = (FieldBinding) fieldBinding; |
97 |
this.binding = (FieldBinding) fieldBinding; |
97 |
|
98 |
|
98 |
if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { |
99 |
if (fieldCanBeUsedAsReference(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { |
99 |
scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); |
100 |
scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); |
100 |
} |
101 |
} |
101 |
return this.resolvedType = this.binding.type; |
102 |
return this.resolvedType = this.binding.type; |
Lines 144-147
Link Here
|
144 |
} |
145 |
} |
145 |
visitor.endVisit(this, scope); |
146 |
visitor.endVisit(this, scope); |
146 |
} |
147 |
} |
|
|
148 |
|
149 |
/** |
150 |
* Same implementation than {@link ASTNode#isFieldUseDeprecated(FieldBinding, Scope, boolean)} without |
151 |
* touching the {@link ExtraCompilerModifiers#AccLocallyUsed} to keep private |
152 |
* fields unused when they are only referenced in javadoc comments. |
153 |
* |
154 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=190970" |
155 |
*/ |
156 |
private final boolean fieldCanBeUsedAsReference(FieldBinding field, Scope scope, boolean isStrictlyAssigned) { |
157 |
|
158 |
if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { |
159 |
AccessRestriction restriction = |
160 |
scope.environment().getAccessRestriction(field.declaringClass.erasure()); |
161 |
if (restriction != null) { |
162 |
scope.problemReporter().forbiddenReference(field, this, |
163 |
restriction.getFieldAccessMessageTemplate(), restriction.getProblemId()); |
164 |
} |
165 |
} |
166 |
|
167 |
if (!field.isViewedAsDeprecated()) return false; |
168 |
|
169 |
// inside same unit - no report |
170 |
if (scope.isDefinedInSameUnit(field.declaringClass)) return false; |
171 |
|
172 |
// if context is deprecated, may avoid reporting |
173 |
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; |
174 |
return true; |
175 |
} |
147 |
} |
176 |
} |