mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8304918: Remove unused decl field from AnnotatedType implementations
Reviewed-by: stsypanov, darcy
This commit is contained in:
parent
00b1eacad6
commit
adf62febe6
2 changed files with 27 additions and 52 deletions
|
@ -46,14 +46,11 @@ public final class AnnotatedTypeFactory {
|
||||||
* @param actualTypeAnnos the type annotations this AnnotatedType has
|
* @param actualTypeAnnos the type annotations this AnnotatedType has
|
||||||
* @param allOnSameTarget all type annotation on the same TypeAnnotationTarget
|
* @param allOnSameTarget all type annotation on the same TypeAnnotationTarget
|
||||||
* as the AnnotatedType being built
|
* as the AnnotatedType being built
|
||||||
* @param decl the declaration having the type use this AnnotatedType
|
|
||||||
* corresponds to
|
|
||||||
*/
|
*/
|
||||||
public static AnnotatedType buildAnnotatedType(Type type,
|
public static AnnotatedType buildAnnotatedType(Type type,
|
||||||
LocationInfo currentLoc,
|
LocationInfo currentLoc,
|
||||||
TypeAnnotation[] actualTypeAnnos,
|
TypeAnnotation[] actualTypeAnnos,
|
||||||
TypeAnnotation[] allOnSameTarget,
|
TypeAnnotation[] allOnSameTarget) {
|
||||||
AnnotatedElement decl) {
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return EMPTY_ANNOTATED_TYPE;
|
return EMPTY_ANNOTATED_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -61,32 +58,27 @@ public final class AnnotatedTypeFactory {
|
||||||
return new AnnotatedArrayTypeImpl(type,
|
return new AnnotatedArrayTypeImpl(type,
|
||||||
currentLoc,
|
currentLoc,
|
||||||
actualTypeAnnos,
|
actualTypeAnnos,
|
||||||
allOnSameTarget,
|
allOnSameTarget);
|
||||||
decl);
|
|
||||||
if (type instanceof Class) {
|
if (type instanceof Class) {
|
||||||
return new AnnotatedTypeBaseImpl(type,
|
return new AnnotatedTypeBaseImpl(type,
|
||||||
currentLoc,
|
currentLoc,
|
||||||
actualTypeAnnos,
|
actualTypeAnnos,
|
||||||
allOnSameTarget,
|
allOnSameTarget);
|
||||||
decl);
|
|
||||||
} else if (type instanceof TypeVariable<?> typeVariable) {
|
} else if (type instanceof TypeVariable<?> typeVariable) {
|
||||||
return new AnnotatedTypeVariableImpl(typeVariable,
|
return new AnnotatedTypeVariableImpl(typeVariable,
|
||||||
currentLoc,
|
currentLoc,
|
||||||
actualTypeAnnos,
|
actualTypeAnnos,
|
||||||
allOnSameTarget,
|
allOnSameTarget);
|
||||||
decl);
|
|
||||||
} else if (type instanceof ParameterizedType paramType) {
|
} else if (type instanceof ParameterizedType paramType) {
|
||||||
return new AnnotatedParameterizedTypeImpl(paramType,
|
return new AnnotatedParameterizedTypeImpl(paramType,
|
||||||
currentLoc,
|
currentLoc,
|
||||||
actualTypeAnnos,
|
actualTypeAnnos,
|
||||||
allOnSameTarget,
|
allOnSameTarget);
|
||||||
decl);
|
|
||||||
} else if (type instanceof WildcardType wildType) {
|
} else if (type instanceof WildcardType wildType) {
|
||||||
return new AnnotatedWildcardTypeImpl(wildType,
|
return new AnnotatedWildcardTypeImpl(wildType,
|
||||||
currentLoc,
|
currentLoc,
|
||||||
actualTypeAnnos,
|
actualTypeAnnos,
|
||||||
allOnSameTarget,
|
allOnSameTarget);
|
||||||
decl);
|
|
||||||
}
|
}
|
||||||
throw new AssertionError("Unknown instance of Type: " + type + "\nThis should not happen.");
|
throw new AssertionError("Unknown instance of Type: " + type + "\nThis should not happen.");
|
||||||
}
|
}
|
||||||
|
@ -123,7 +115,7 @@ public final class AnnotatedTypeFactory {
|
||||||
|
|
||||||
static final TypeAnnotation[] EMPTY_TYPE_ANNOTATION_ARRAY = new TypeAnnotation[0];
|
static final TypeAnnotation[] EMPTY_TYPE_ANNOTATION_ARRAY = new TypeAnnotation[0];
|
||||||
static final AnnotatedType EMPTY_ANNOTATED_TYPE = new AnnotatedTypeBaseImpl(null, LocationInfo.BASE_LOCATION,
|
static final AnnotatedType EMPTY_ANNOTATED_TYPE = new AnnotatedTypeBaseImpl(null, LocationInfo.BASE_LOCATION,
|
||||||
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY, null);
|
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY);
|
||||||
static final AnnotatedType[] EMPTY_ANNOTATED_TYPE_ARRAY = new AnnotatedType[0];
|
static final AnnotatedType[] EMPTY_ANNOTATED_TYPE_ARRAY = new AnnotatedType[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -134,16 +126,13 @@ public final class AnnotatedTypeFactory {
|
||||||
|
|
||||||
private static class AnnotatedTypeBaseImpl implements AnnotatedType {
|
private static class AnnotatedTypeBaseImpl implements AnnotatedType {
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final AnnotatedElement decl;
|
|
||||||
private final LocationInfo location;
|
private final LocationInfo location;
|
||||||
private final TypeAnnotation[] allOnSameTargetTypeAnnotations;
|
private final TypeAnnotation[] allOnSameTargetTypeAnnotations;
|
||||||
private final Map<Class <? extends Annotation>, Annotation> annotations;
|
private final Map<Class <? extends Annotation>, Annotation> annotations;
|
||||||
|
|
||||||
AnnotatedTypeBaseImpl(Type type, LocationInfo location,
|
AnnotatedTypeBaseImpl(Type type, LocationInfo location,
|
||||||
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations,
|
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations) {
|
||||||
AnnotatedElement decl) {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.decl = decl;
|
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.allOnSameTargetTypeAnnotations = allOnSameTargetTypeAnnotations;
|
this.allOnSameTargetTypeAnnotations = allOnSameTargetTypeAnnotations;
|
||||||
this.annotations = TypeAnnotationParser.mapTypeAnnotations(location.filter(actualTypeAnnotations));
|
this.annotations = TypeAnnotationParser.mapTypeAnnotations(location.filter(actualTypeAnnotations));
|
||||||
|
@ -202,7 +191,7 @@ public final class AnnotatedTypeFactory {
|
||||||
LocationInfo outerLoc = getLocation().popLocation((byte)1);
|
LocationInfo outerLoc = getLocation().popLocation((byte)1);
|
||||||
if (outerLoc == null) {
|
if (outerLoc == null) {
|
||||||
return buildAnnotatedType(owner, LocationInfo.BASE_LOCATION,
|
return buildAnnotatedType(owner, LocationInfo.BASE_LOCATION,
|
||||||
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY, getDecl());
|
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY);
|
||||||
}
|
}
|
||||||
TypeAnnotation[]all = getTypeAnnotations();
|
TypeAnnotation[]all = getTypeAnnotations();
|
||||||
List<TypeAnnotation> l = new ArrayList<>(all.length);
|
List<TypeAnnotation> l = new ArrayList<>(all.length);
|
||||||
|
@ -211,7 +200,7 @@ public final class AnnotatedTypeFactory {
|
||||||
if (t.getLocationInfo().isSameLocationInfo(outerLoc))
|
if (t.getLocationInfo().isSameLocationInfo(outerLoc))
|
||||||
l.add(t);
|
l.add(t);
|
||||||
|
|
||||||
return buildAnnotatedType(owner, outerLoc, l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY), all, getDecl());
|
return buildAnnotatedType(owner, outerLoc, l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY), all);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,16 +274,12 @@ public final class AnnotatedTypeFactory {
|
||||||
final TypeAnnotation[] getTypeAnnotations() {
|
final TypeAnnotation[] getTypeAnnotations() {
|
||||||
return allOnSameTargetTypeAnnotations;
|
return allOnSameTargetTypeAnnotations;
|
||||||
}
|
}
|
||||||
final AnnotatedElement getDecl() {
|
|
||||||
return decl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class AnnotatedArrayTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedArrayType {
|
private static final class AnnotatedArrayTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedArrayType {
|
||||||
AnnotatedArrayTypeImpl(Type type, LocationInfo location,
|
AnnotatedArrayTypeImpl(Type type, LocationInfo location,
|
||||||
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations,
|
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations) {
|
||||||
AnnotatedElement decl) {
|
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations);
|
||||||
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -303,8 +288,7 @@ public final class AnnotatedTypeFactory {
|
||||||
return AnnotatedTypeFactory.buildAnnotatedType(t,
|
return AnnotatedTypeFactory.buildAnnotatedType(t,
|
||||||
nestingForType(t, getLocation().pushArray()),
|
nestingForType(t, getLocation().pushArray()),
|
||||||
getTypeAnnotations(),
|
getTypeAnnotations(),
|
||||||
getTypeAnnotations(),
|
getTypeAnnotations());
|
||||||
getDecl());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -367,9 +351,8 @@ public final class AnnotatedTypeFactory {
|
||||||
|
|
||||||
private static final class AnnotatedTypeVariableImpl extends AnnotatedTypeBaseImpl implements AnnotatedTypeVariable {
|
private static final class AnnotatedTypeVariableImpl extends AnnotatedTypeBaseImpl implements AnnotatedTypeVariable {
|
||||||
AnnotatedTypeVariableImpl(TypeVariable<?> type, LocationInfo location,
|
AnnotatedTypeVariableImpl(TypeVariable<?> type, LocationInfo location,
|
||||||
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations,
|
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations) {
|
||||||
AnnotatedElement decl) {
|
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations);
|
||||||
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -406,9 +389,8 @@ public final class AnnotatedTypeFactory {
|
||||||
private static final class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl
|
private static final class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl
|
||||||
implements AnnotatedParameterizedType {
|
implements AnnotatedParameterizedType {
|
||||||
AnnotatedParameterizedTypeImpl(ParameterizedType type, LocationInfo location,
|
AnnotatedParameterizedTypeImpl(ParameterizedType type, LocationInfo location,
|
||||||
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations,
|
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations) {
|
||||||
AnnotatedElement decl) {
|
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations);
|
||||||
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -426,8 +408,7 @@ public final class AnnotatedTypeFactory {
|
||||||
res[i] = buildAnnotatedType(arguments[i],
|
res[i] = buildAnnotatedType(arguments[i],
|
||||||
newLoc,
|
newLoc,
|
||||||
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
|
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
|
||||||
getTypeAnnotations(),
|
getTypeAnnotations());
|
||||||
getDecl());
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +422,7 @@ public final class AnnotatedTypeFactory {
|
||||||
LocationInfo outerLoc = getLocation().popLocation((byte)1);
|
LocationInfo outerLoc = getLocation().popLocation((byte)1);
|
||||||
if (outerLoc == null) {
|
if (outerLoc == null) {
|
||||||
return buildAnnotatedType(owner, LocationInfo.BASE_LOCATION,
|
return buildAnnotatedType(owner, LocationInfo.BASE_LOCATION,
|
||||||
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY, getDecl());
|
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY);
|
||||||
}
|
}
|
||||||
TypeAnnotation[]all = getTypeAnnotations();
|
TypeAnnotation[]all = getTypeAnnotations();
|
||||||
List<TypeAnnotation> l = new ArrayList<>(all.length);
|
List<TypeAnnotation> l = new ArrayList<>(all.length);
|
||||||
|
@ -450,7 +431,7 @@ public final class AnnotatedTypeFactory {
|
||||||
if (t.getLocationInfo().isSameLocationInfo(outerLoc))
|
if (t.getLocationInfo().isSameLocationInfo(outerLoc))
|
||||||
l.add(t);
|
l.add(t);
|
||||||
|
|
||||||
return buildAnnotatedType(owner, outerLoc, l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY), all, getDecl());
|
return buildAnnotatedType(owner, outerLoc, l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY), all);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParameterizedType getParameterizedType() {
|
private ParameterizedType getParameterizedType() {
|
||||||
|
@ -494,9 +475,8 @@ public final class AnnotatedTypeFactory {
|
||||||
private static final class AnnotatedWildcardTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedWildcardType {
|
private static final class AnnotatedWildcardTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedWildcardType {
|
||||||
private final boolean hasUpperBounds;
|
private final boolean hasUpperBounds;
|
||||||
AnnotatedWildcardTypeImpl(WildcardType type, LocationInfo location,
|
AnnotatedWildcardTypeImpl(WildcardType type, LocationInfo location,
|
||||||
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations,
|
TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations) {
|
||||||
AnnotatedElement decl) {
|
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations);
|
||||||
super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl);
|
|
||||||
hasUpperBounds = (type.getLowerBounds().length == 0);
|
hasUpperBounds = (type.getLowerBounds().length == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,8 +486,7 @@ public final class AnnotatedTypeFactory {
|
||||||
return new AnnotatedType[] { buildAnnotatedType(Object.class,
|
return new AnnotatedType[] { buildAnnotatedType(Object.class,
|
||||||
LocationInfo.BASE_LOCATION,
|
LocationInfo.BASE_LOCATION,
|
||||||
EMPTY_TYPE_ANNOTATION_ARRAY,
|
EMPTY_TYPE_ANNOTATION_ARRAY,
|
||||||
EMPTY_TYPE_ANNOTATION_ARRAY,
|
EMPTY_TYPE_ANNOTATION_ARRAY)
|
||||||
null)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return getAnnotatedBounds(getWildcardType().getUpperBounds());
|
return getAnnotatedBounds(getWildcardType().getUpperBounds());
|
||||||
|
@ -538,8 +517,7 @@ public final class AnnotatedTypeFactory {
|
||||||
res[i] = buildAnnotatedType(bounds[i],
|
res[i] = buildAnnotatedType(bounds[i],
|
||||||
newLoc,
|
newLoc,
|
||||||
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
|
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
|
||||||
getTypeAnnotations(),
|
getTypeAnnotations());
|
||||||
getDecl());
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,7 @@ public final class TypeAnnotationParser {
|
||||||
return AnnotatedTypeFactory.buildAnnotatedType(type,
|
return AnnotatedTypeFactory.buildAnnotatedType(type,
|
||||||
AnnotatedTypeFactory.nestingForType(type, LocationInfo.BASE_LOCATION),
|
AnnotatedTypeFactory.nestingForType(type, LocationInfo.BASE_LOCATION),
|
||||||
typeAnnotations,
|
typeAnnotations,
|
||||||
typeAnnotations,
|
typeAnnotations);
|
||||||
decl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,8 +155,7 @@ public final class TypeAnnotationParser {
|
||||||
result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
|
result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
|
||||||
AnnotatedTypeFactory.nestingForType(types[i], LocationInfo.BASE_LOCATION),
|
AnnotatedTypeFactory.nestingForType(types[i], LocationInfo.BASE_LOCATION),
|
||||||
typeAnnotations,
|
typeAnnotations,
|
||||||
typeAnnotations,
|
typeAnnotations);
|
||||||
decl);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -303,8 +301,7 @@ public final class TypeAnnotationParser {
|
||||||
res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
|
res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
|
||||||
AnnotatedTypeFactory.nestingForType(bounds[i], loc),
|
AnnotatedTypeFactory.nestingForType(bounds[i], loc),
|
||||||
typeAnnotations,
|
typeAnnotations,
|
||||||
typeAnnotations,
|
typeAnnotations);
|
||||||
decl);
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue