Skip to content

Commit

Permalink
Small formatting tweaks in org.checkerframework.framework.type (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl authored Dec 23, 2024
1 parent d73d8bf commit 5df41f5
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public void viewpointAdaptConstructor(
AnnotatedTypeMirror receiverType,
ExecutableElement constructorElt,
AnnotatedExecutableType constructorType) {

// constructorType's typevar are not substituted when calling viewpointAdaptConstructor
AnnotatedExecutableType unsubstitutedConstructorType = constructorType.deepCopy();

Expand Down Expand Up @@ -336,7 +335,6 @@ protected AnnotatedTypeMirror combineAnnotationWithType(
return aat;
} else if (declared.getKind() == TypeKind.WILDCARD) {
AnnotatedWildcardType awt = (AnnotatedWildcardType) declared.shallowCopy();

IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror> mappings =
new IdentityHashMap<>();

Expand All @@ -361,7 +359,6 @@ protected AnnotatedTypeMirror combineAnnotationWithType(
}

AnnotatedTypeMirror result = AnnotatedTypeCopierWithReplacement.replace(awt, mappings);

return result;
} else if (declared.getKind() == TypeKind.NULL) {
AnnotatedNullType ant = (AnnotatedNullType) declared.shallowCopy(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ protected <T extends AnnotatedTypeMirror> T makeOrReturnCopy(
*/
@SuppressWarnings("unchecked")
protected <T extends AnnotatedTypeMirror> T makeCopy(T original) {

T copy =
(T)
AnnotatedTypeMirror.createType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,6 @@ protected Set<Class<? extends Annotation>> getFieldInvariantDeclarationAnnotatio
*/
public List<AnnotatedTypeParameterBounds> typeVariablesFromUse(
AnnotatedDeclaredType type, TypeElement element) {

AnnotatedDeclaredType generic = getAnnotatedType(element);
List<AnnotatedTypeMirror> targs = type.getTypeArguments();
List<AnnotatedTypeMirror> tvars = generic.getTypeArguments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ private void loadBundledAnnotationClasses() {
throw new BugInCF(
"AnnotationClassLoader: cannot open the Jar file " + resourceURL.getFile());
}

} else if (resourceURL != null && resourceURL.getProtocol().contentEquals("file")) {
// If the checker class file is found within the file system itself within some
// directory (usually development build directories), then process the package as a file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ public Void visitDeclared(AnnotatedDeclaredType type, Void aVoid) {

@Override
public Void visitIntersection(AnnotatedIntersectionType type, Void aVoid) {

if (intersections.containsKey(type.getUnderlyingType())) {
return null;
}
Expand All @@ -393,7 +392,6 @@ public Void visitIntersection(AnnotatedIntersectionType type, Void aVoid) {

@Override
public Void visitUnion(AnnotatedUnionType type, Void aVoid) {

List<AnnotatedDeclaredType> alts = type.getAlternatives();
for (int i = 0; i < alts.size(); i++) {
AnnotatedDeclaredType alt = alts.get(i);
Expand Down Expand Up @@ -458,7 +456,6 @@ public Void visitNull(AnnotatedNullType type, Void aVoid) {
public Void visitWildcard(AnnotatedWildcardType wildcard, Void aVoid) {
if (wildcard.getSuperBoundField() == null) {
initializeSuperBound(wildcard);

} else {
throw new BugInCF(
"Wildcard super field should not be initialized:%n"
Expand Down Expand Up @@ -1195,7 +1192,6 @@ protected void replaceTypeInternal(

@Override
protected AnnotatedTypeMirror getTypeInternal(AnnotatedTypeMirror parent) {

AnnotatedTypeVariable parentAtv = (AnnotatedTypeVariable) parent;
if (parentAtv.getLowerBoundField() != null) {
return parentAtv.getLowerBoundField();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ public String visitWildcard(AnnotatedWildcardType type, Set<AnnotatedTypeMirror>

sb.append("?");
if (!visiting.contains(type)) {

try {
visiting.add(type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ private void apply(
AnnotationMirror top) {
AnnotationMirror primary = type.getAnnotationInHierarchy(top);
if (inferred == null) {

if (primary == null) {
// Type doesn't have a primary either, nothing to remove
} else if (type.getKind() == TypeKind.TYPEVAR) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,6 @@ protected boolean visitWildcard_Type(
// If both have primary annotations then just check the primary annotations
// as the bounds are the same.
return isPrimarySubtype(subtype, supertype);

} else if (!subtypeHasAnno
&& !supertypeHasAnno
&& areEqualInHierarchy(subtype, supertype)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ protected boolean compare(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2)
if (type1 == type2) {
return true;
}

if (type1 == null || type2 == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ public DefaultForTypeAnnotator getDefaultForTypeAnnotator() {
*/
@SuppressWarnings({"unchecked", "rawtypes"})
protected FlowAnalysis createFlowAnalysis() {

// Try to reflectively load the visitor.
Class<?> checkerClass = checker.getClass();

Expand Down Expand Up @@ -687,7 +686,6 @@ protected FlowAnalysis createFlowAnalysis() {
// However, we ran into issues in callers of the method if we used that type.
public TransferFunction createFlowTransferFunction(
CFAbstractAnalysis<Value, Store, TransferFunction> analysis) {

// Try to reflectively load the visitor.
Class<?> checkerClass = checker.getClass();

Expand Down Expand Up @@ -996,7 +994,6 @@ public AnnotatedTypeMirror getResultingTypeOfConstructorMemberReference(
*/
public @Nullable AnnotationMirrorSet getAnnotationsFromJavaExpression(
JavaExpression expr, Tree tree) {

// Look in the store
if (CFAbstractStore.canInsertJavaExpression(expr)) {
Store store = getStoreBefore(tree);
Expand Down Expand Up @@ -1871,7 +1868,6 @@ public AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree) {
res = getAnnotatedType(lhsTree);
// Value of shouldCache no longer used below, so no need to reset.
break;

case MEMBER_SELECT:
case ARRAY_ACCESS:
res = getAnnotatedType(lhsTree);
Expand Down Expand Up @@ -2659,11 +2655,9 @@ public final boolean isRelevant(AnnotatedTypeMirror tm) {
* @return true if users can write type annotations from this type system on the given Java type
*/
protected boolean isRelevantImpl(TypeMirror tm) {

if (relevantJavaTypes == null) {
return true;
}

if (relevantJavaTypes.contains(tm)) {
return true;
}
Expand Down Expand Up @@ -3110,14 +3104,12 @@ protected List<AnnotationMirror> getPreOrPostconditionAnnotations(
AnnotatedTypeMirror declaredType,
Analysis.BeforeOrAfter preOrPost,
@Nullable List<AnnotationMirror> preconds) {

// Do not generate RequiresQualifier annotations for "this" or parameter expressions.
if (preOrPost == BeforeOrAfter.BEFORE
&& ("this".equals(expression)
|| formalParameterPattern.matcher(expression).matches())) {
return null;
}

if (!qualifier.getElementValues().isEmpty()) {
// @RequiresQualifier and @EnsuresQualifier do not yet support annotations with
// elements/arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public AnnotatedTypeMirror visitAnnotatedType(AnnotatedTypeTree tree, AnnotatedT

@Override
public AnnotatedTypeMirror visitTypeCast(TypeCastTree tree, AnnotatedTypeFactory f) {

// Use the annotated type of the type in the cast.
return f.fromTypeTree(tree.getType());
}
Expand Down Expand Up @@ -166,7 +165,6 @@ public AnnotatedTypeMirror visitLambdaExpression(

@Override
public AnnotatedTypeMirror visitAssignment(AssignmentTree tree, AnnotatedTypeFactory f) {

// Recurse on the type of the variable.
return visit(tree.getVariable(), f);
}
Expand Down Expand Up @@ -319,7 +317,6 @@ public AnnotatedTypeMirror visitArrayAccess(ArrayAccessTree tree, AnnotatedTypeF

@Override
public AnnotatedTypeMirror visitNewArray(NewArrayTree tree, AnnotatedTypeFactory f) {

// Don't use fromTypeTree here, because tree.getType() is not an array type!
AnnotatedArrayType result = (AnnotatedArrayType) f.type(tree);

Expand Down Expand Up @@ -424,14 +421,12 @@ public AnnotatedTypeMirror visitMethodInvocation(

@Override
public AnnotatedTypeMirror visitParenthesized(ParenthesizedTree tree, AnnotatedTypeFactory f) {

// Recurse on the expression inside the parens.
return visit(tree.getExpression(), f);
}

@Override
public AnnotatedTypeMirror visitWildcard(WildcardTree tree, AnnotatedTypeFactory f) {

AnnotatedTypeMirror bound = visit(tree.getBound(), f);

AnnotatedTypeMirror result = f.type(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public AnnotatedTypeMirror visitArrayType(ArrayTypeTree tree, AnnotatedTypeFacto
@Override
public AnnotatedTypeMirror visitParameterizedType(
ParameterizedTypeTree tree, AnnotatedTypeFactory f) {

ClassSymbol baseType = (ClassSymbol) TreeUtils.elementFromTree(tree.getType());
updateWildcardBounds(tree.getTypeArguments(), baseType.getTypeParameters());

Expand Down Expand Up @@ -193,7 +192,6 @@ public AnnotatedTypeMirror visitPrimitiveType(PrimitiveTypeTree tree, AnnotatedT
@Override
public AnnotatedTypeVariable visitTypeParameter(
TypeParameterTree tree, @FindDistinct AnnotatedTypeFactory f) {

List<AnnotatedTypeMirror> bounds = new ArrayList<>(tree.getBounds().size());
for (Tree t : tree.getBounds()) {
AnnotatedTypeMirror bound;
Expand Down Expand Up @@ -229,9 +227,7 @@ public AnnotatedTypeVariable visitTypeParameter(

@Override
public AnnotatedTypeMirror visitWildcard(WildcardTree tree, AnnotatedTypeFactory f) {

AnnotatedTypeMirror bound = visit(tree.getBound(), f);

AnnotatedTypeMirror result = f.type(tree);
assert result instanceof AnnotatedWildcardType;

Expand Down Expand Up @@ -318,7 +314,6 @@ private AnnotatedTypeVariable getTypeVariableFromDeclaration(
*/
private int findIndex(
List<? extends TypeParameterElement> typeParameters, TypeParameterElement type) {

TypeVariable typeVariable = (TypeVariable) type.asType();

for (int i = 0; i < typeParameters.size(); i++) {
Expand All @@ -332,7 +327,6 @@ private int findIndex(

@Override
public AnnotatedTypeMirror visitIdentifier(IdentifierTree tree, AnnotatedTypeFactory f) {

AnnotatedTypeMirror type = f.type(tree);

if (type.getKind() == TypeKind.TYPEVAR) {
Expand All @@ -344,7 +338,6 @@ public AnnotatedTypeMirror visitIdentifier(IdentifierTree tree, AnnotatedTypeFac

@Override
public AnnotatedTypeMirror visitMemberSelect(MemberSelectTree tree, AnnotatedTypeFactory f) {

AnnotatedTypeMirror type = f.type(tree);

if (type.getKind() == TypeKind.TYPEVAR) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ protected <T extends AnnotatedTypeMirror> T makeCopy(T original) {
public AnnotatedTypeMirror visitTypeVariable(
AnnotatedTypeVariable original,
IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror> originalToCopy) {

if (visitingExecutableTypeParam) {
// AnnotatedExecutableType differs from AnnotatedDeclaredType in that its list of
// type parameters cannot be adapted in place since the
Expand All @@ -161,7 +160,6 @@ public AnnotatedTypeMirror visitTypeVariable(
// AnnotatedTypeVariable's will remain
visitingExecutableTypeParam = false;
return super.visitTypeVariable(original, originalToCopy);

} else {
Element typeVarElem = original.getUnderlyingType().asElement();
if (elementToArgMap.containsKey(typeVarElem)) {
Expand Down

0 comments on commit 5df41f5

Please sign in to comment.