Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public Set<Class<? extends Annotation>> getInvalidConstructorReturnTypeAnnotatio
* Returns whether or not {@code field} has the invariant annotation.
*
* <p>This method is a convenience method for {@link
* #hasFieldInvariantAnnotation(AnnotatedTypeMirror)}.
* #hasFieldInvariantAnnotation(AnnotatedTypeMirror, VariableElement)}.
*
* <p>If the {@code field} is a type variable, this method returns true if any possible
* instantiation of the type parameter could have the invariant annotation. See {@link
Expand All @@ -185,7 +185,8 @@ public Set<Class<? extends Annotation>> getInvalidConstructorReturnTypeAnnotatio
*/
protected final boolean hasFieldInvariantAnnotation(VariableTree field) {
AnnotatedTypeMirror type = getAnnotatedType(field);
return hasFieldInvariantAnnotation(type);
VariableElement fieldElement = TreeUtils.elementFromDeclaration(field);
return hasFieldInvariantAnnotation(type, fieldElement);
}

/**
Expand All @@ -196,9 +197,12 @@ protected final boolean hasFieldInvariantAnnotation(VariableTree field) {
* NullnessAnnotatedTypeFactory#hasFieldInvariantAnnotation(VariableTree)} for an example.
*
* @param type of field that might have invariant annotation
* @param fieldElement the field element, which can be used to check annotations on the
* declaration
* @return whether or not the type has the invariant annotation
*/
protected abstract boolean hasFieldInvariantAnnotation(AnnotatedTypeMirror type);
protected abstract boolean hasFieldInvariantAnnotation(
AnnotatedTypeMirror type, VariableElement fieldElement);

/**
* Creates a {@link UnderInitialization} annotation with the given type as its type frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected void markInvariantFieldsAsInitialized(
continue;
}
AnnotatedTypeMirror fieldType = atypeFactory.getAnnotatedType(field);
if (atypeFactory.hasFieldInvariantAnnotation(fieldType)) {
if (atypeFactory.hasFieldInvariantAnnotation(fieldType, field)) {
result.add(field);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@ public AnnotationMirror getFieldInvariantAnnotation() {
* @return whether or not type has the invariant annotation
*/
@Override
protected boolean hasFieldInvariantAnnotation(AnnotatedTypeMirror type) {
protected boolean hasFieldInvariantAnnotation(
AnnotatedTypeMirror type, VariableElement fieldElement) {
AnnotationMirror invariant = getFieldInvariantAnnotation();
Set<AnnotationMirror> lowerBounds =
AnnotatedTypes.findEffectiveLowerBoundAnnotations(qualHierarchy, type);
Expand Down