Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Oct 9, 2024
1 parent 3ed138f commit d705317
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,9 @@ private static boolean isDeclarationAnnotation(Symbol anno) {
}

/**
* Checks whether the annotation is at the right location for nested types. Raises an error iff
* the type is a field access expression, the annotation is (or also) type-use and the annotation
* is not applied on the innermost type.
* Checks whether any {@code @Nullable} annotation is at the right location for nested types.
* Raises an error iff the type is a field access expression (for an inner class type), the
* annotation is type use, and the annotation is not applied on the innermost type.
*
* @param annotations The annotations to check
* @param type The tree representing the type structure
Expand All @@ -1547,7 +1547,6 @@ private void checkNullableAnnotationPositionInType(
List<? extends AnnotationTree> annotations, Tree type, Tree tree, VisitorState state) {

// Early return if the type is not a nested or inner class reference.

if (!(type instanceof MemberSelectTree)) {
return;
}
Expand All @@ -1563,6 +1562,12 @@ private void checkNullableAnnotationPositionInType(
if (sym == null) {
continue;
}

String qualifiedName = sym.getQualifiedName().toString();
if (!isNullableAnnotation(qualifiedName, config)) {
continue;
}

if (!isTypeUseAnnotation(sym)) {
continue;
}
Expand All @@ -1572,13 +1577,8 @@ private void checkNullableAnnotationPositionInType(
continue;
}

String qualifiedName = sym.getQualifiedName().toString();
if (!isNullableAnnotation(qualifiedName, config)) {
continue;
}

if (state.getEndPosition(annotation) < endOfOuterType) {

// annotation is not on the inner-most type
ErrorMessage errorMessage =
new ErrorMessage(
MessageTypes.NULLABLE_ON_WRONG_NESTED_CLASS_LEVEL,
Expand Down

0 comments on commit d705317

Please sign in to comment.