Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Nov 27, 2023
1 parent f7a16a7 commit 8e6784c
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,30 @@ private Node getMapNodeForKeySetIteratorCall(MethodInvocationNode invocationNode
return null;
}

/**
* Checks if an invocation node represents a call to a method on a given type
*
* @param invocationNode the invocation node
* @param containingTypeSupplier supplier for the type containing the method
* @param methodName name of the method
* @return true if the invocation node represents a call to the method on the type
*/
private boolean isCallToMethod(
MethodInvocationNode invocationNode,
Supplier<Type> containingTypeSupplier,
String methodName) {
MethodInvocationTree invocationTree = invocationNode.getTree();
Symbol.MethodSymbol symbol = ASTHelpers.getSymbol(invocationTree);
return symbol != null
&& symbol.getSimpleName().contentEquals(methodName)
&& ASTHelpers.isSubtype(
ASTHelpers.getReceiverType(invocationTree), containingTypeSupplier.get(state), state);
if (symbol != null && symbol.getSimpleName().contentEquals(methodName)) {
// NOTE: previously we checked if symbol.owner.type was a subtype of the containing type.
// However, symbol.owner.type refers to the static type at the call site, which might be a
// supertype of the containing type with some Java compilers. Instead, we check if the type
// of the receiver at the invocation is a subtype of the containing type. See
// https://github.com/uber/NullAway/issues/866.
return ASTHelpers.isSubtype(
ASTHelpers.getReceiverType(invocationTree), containingTypeSupplier.get(state), state);
}
return false;

Check warning on line 660 in nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessPropagation.java

View check run for this annotation

Codecov / codecov/patch

nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessPropagation.java#L660

Added line #L660 was not covered by tests
}

/**
Expand Down

0 comments on commit 8e6784c

Please sign in to comment.