Skip to content

Commit 397154a

Browse files
members of a deprecated type are not implicitly deprecated (#4564)
Remove everything relating to AccDeprecatedImplicitly Test from #4562 Fixes #4553
1 parent 83c70c8 commit 397154a

File tree

25 files changed

+163
-332
lines changed

25 files changed

+163
-332
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,6 @@ public TypeBinding resolveType(BlockScope blockScope, boolean skipKosherCheck) {
290290
blockScope.enclosingSourceType());
291291
this.binding.typeVariables = Binding.NO_TYPE_VARIABLES;
292292

293-
MethodScope enm = this.scope.namedMethodScope();
294-
MethodBinding enmb = enm == null ? null : enm.referenceMethodBinding();
295-
if (enmb != null && enmb.isViewedAsDeprecated()) {
296-
this.binding.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
297-
this.binding.tagBits |= enmb.tagBits & TagBits.AnnotationTerminallyDeprecated;
298-
}
299-
300293
boolean argumentsHaveErrors = false;
301294
if (haveDescriptor) {
302295
int parametersLength = this.descriptor.parameters.length;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,9 +1852,6 @@ public void updateSupertypesWithAnnotations(Map<ReferenceBinding,ReferenceBindin
18521852
if (this.binding == null)
18531853
return;
18541854
this.binding.getAnnotationTagBits();
1855-
if (this.binding instanceof MemberTypeBinding) {
1856-
((MemberTypeBinding) this.binding).updateDeprecationFromEnclosing();
1857-
}
18581855
Map<ReferenceBinding,ReferenceBinding> updates = new HashMap<>();
18591856
if (this.typeParameters != null) {
18601857
for (TypeParameter typeParameter : this.typeParameters) {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType,
328328
this.tagBits |= TagBits.HasUnresolvedEnclosingType;
329329
if (enclosingType().isStrictfp())
330330
this.modifiers |= ClassFileConstants.AccStrictfp;
331-
if (enclosingType().isDeprecated())
332-
this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
333331
}
334332
if (needFieldsAndMethods)
335333
cachePartsFrom(binaryType, true);
@@ -598,19 +596,6 @@ private void cachePartsFrom2(IBinaryType binaryType, boolean needFieldsAndMethod
598596
IBinaryField[] iFields = binaryType.getFields();
599597
createFields(iFields, binaryType, sourceLevel, missingTypeNames, FIELD_INITIALIZATION);
600598
IBinaryMethod[] iMethods = createMethods(binaryType.getMethods(), binaryType, sourceLevel, missingTypeNames);
601-
boolean isViewedAsDeprecated = isViewedAsDeprecated();
602-
if (isViewedAsDeprecated) {
603-
for (FieldBinding field : this.fields) {
604-
if (!field.isDeprecated()) {
605-
field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
606-
}
607-
}
608-
for (MethodBinding method : this.methods) {
609-
if (!method.isDeprecated()) {
610-
method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
611-
}
612-
}
613-
}
614599
if (this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled) {
615600
if (iComponents != null) {
616601
for (int i = 0; i < iComponents.length; i++) {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -613,35 +613,20 @@ private void checkAndSetModifiers() {
613613
if (methodScope.isInsideInitializer()) {
614614
SourceTypeBinding type = ((TypeDeclaration) methodScope.referenceContext).binding;
615615

616-
// inside field declaration ? check field modifier to see if deprecated
617-
if (methodScope.initializedField != null) {
618-
// currently inside this field initialization
619-
if (methodScope.initializedField.isViewedAsDeprecated() && !sourceType.isDeprecated())
620-
modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
621-
} else {
622-
if (type.isStrictfp())
623-
modifiers |= ClassFileConstants.AccStrictfp;
624-
if (type.isViewedAsDeprecated() && !sourceType.isDeprecated())
625-
modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
626-
}
616+
if (methodScope.initializedField == null && type.isStrictfp())
617+
modifiers |= ClassFileConstants.AccStrictfp;
627618
} else {
628619
MethodBinding method = ((AbstractMethodDeclaration) methodScope.referenceContext).binding;
629620
if (method != null) {
630621
if (method.isStrictfp())
631622
modifiers |= ClassFileConstants.AccStrictfp;
632-
if (method.isViewedAsDeprecated() && !sourceType.isDeprecated())
633-
modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
634623
}
635624
}
636625
break;
637626
case CLASS_SCOPE :
638627
// local member
639628
if (enclosingType.isStrictfp())
640629
modifiers |= ClassFileConstants.AccStrictfp;
641-
if (enclosingType.isViewedAsDeprecated() && !sourceType.isDeprecated()) {
642-
modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
643-
sourceType.tagBits |= enclosingType.tagBits & TagBits.AnnotationTerminallyDeprecated;
644-
}
645630
break;
646631
}
647632
scope = scope.parent;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -37,7 +37,7 @@ public interface ExtraCompilerModifiers { // modifier constant
3737
final int AccFromClassFile = ASTNode.Bit20;
3838
final int AccDefaultAbstract = ASTNode.Bit20;
3939
// bit21 - use by ClassFileConstants.AccDeprecated
40-
final int AccDeprecatedImplicitly = ASTNode.Bit22; // record whether deprecated itself or contained by a deprecated type
40+
// bit22 was used for AccDeprecatedImplicitly
4141
final int AccAlternateModifierProblem = ASTNode.Bit23;
4242
final int AccSemicolonBody = ASTNode.Bit25;
4343
final int AccRecord = ASTNode.Bit25;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public final boolean isUsedOnlyInCompound() {
371371
*/
372372

373373
public final boolean isViewedAsDeprecated() {
374-
return (this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0;
374+
return (this.modifiers & ClassFileConstants.AccDeprecated) != 0;
375375
}
376376
/* Answer true if the receiver is a volatile field
377377
*/

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,6 @@ public void initializeDeprecatedAnnotationTagBits() {
7272
}
7373
if ((this.extendedTagBits & ExtendedTagBits.DeprecatedAnnotationResolved) == 0) {
7474
super.initializeDeprecatedAnnotationTagBits();
75-
if ((this.tagBits & TagBits.AnnotationDeprecated) == 0) {
76-
// check enclosing type
77-
updateDeprecationFromEnclosing();
78-
}
79-
}
80-
}
81-
82-
public void updateDeprecationFromEnclosing() {
83-
ReferenceBinding enclosing = enclosingType();
84-
if ((enclosing.extendedTagBits & ExtendedTagBits.DeprecatedAnnotationResolved) == 0) {
85-
enclosing.initializeDeprecatedAnnotationTagBits();
86-
}
87-
if (enclosing.isViewedAsDeprecated()) {
88-
this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
89-
this.tagBits |= (enclosing.tagBits & TagBits.AnnotationTerminallyDeprecated);
9075
}
9176
}
9277

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ public boolean isPolymorphic() {
984984
/* Answer true if the receiver's declaring type is deprecated (or any of its enclosing types)
985985
*/
986986
public final boolean isViewedAsDeprecated() {
987-
return (this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0;
987+
return (this.modifiers & ClassFileConstants.AccDeprecated) != 0;
988988
}
989989

990990
@Override

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2024 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -1837,12 +1837,8 @@ public final boolean isUsed() {
18371837
* Answer true if the receiver is deprecated (or any of its enclosing types)
18381838
*/
18391839
public final boolean isViewedAsDeprecated() {
1840-
if ((this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0)
1840+
if ((this.modifiers & ClassFileConstants.AccDeprecated) != 0)
18411841
return true;
1842-
if (getPackage().isViewedAsDeprecated()) {
1843-
this.tagBits |= (getPackage().tagBits & TagBits.AnnotationTerminallyDeprecated);
1844-
return true;
1845-
}
18461842
return false;
18471843
}
18481844
public boolean isImplicitType() {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,10 +3890,6 @@ public boolean isInsideDeprecatedCode(){
38903890
MethodBinding context = ((AbstractMethodDeclaration) referenceContext).binding;
38913891
if (context != null && context.isViewedAsDeprecated())
38923892
return true;
3893-
} else if (referenceContext instanceof LambdaExpression) {
3894-
MethodBinding context = ((LambdaExpression) referenceContext).binding;
3895-
if (context != null && context.isViewedAsDeprecated())
3896-
return true;
38973893
} else if (referenceContext instanceof ModuleDeclaration) {
38983894
ModuleBinding context = ((ModuleDeclaration) referenceContext).binding;
38993895
return context != null && context.isDeprecated();
@@ -3929,6 +3925,8 @@ public boolean isInsideDeprecatedCode(){
39293925
}
39303926
}
39313927
}
3928+
if (this.parent != null)
3929+
return this.parent.isInsideDeprecatedCode();
39323930
return false;
39333931
}
39343932

0 commit comments

Comments
 (0)