Skip to content

Commit

Permalink
updating the logic for the test case:testForMethodReferenceInAnAssign…
Browse files Browse the repository at this point in the history
…ment to modify the caller instead of the method
  • Loading branch information
akulk022 committed Oct 13, 2023
1 parent 0b49a42 commit 06d157f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
11 changes: 3 additions & 8 deletions nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.sun.source.tree.AssignmentTree;
import com.sun.source.tree.ConditionalExpressionTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.MemberReferenceTree;
import com.sun.source.tree.MemberSelectTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.MethodTree;
Expand Down Expand Up @@ -877,13 +876,9 @@ public static Nullness getGenericMethodParameterNullness(
int parameterIndex,
Symbol.MethodSymbol method,
Symbol enclosingSymbol,
@Nullable MemberReferenceTree memberReferenceTree,
VisitorState state,
Config config) {
Type enclosingType =
(memberReferenceTree != null)
? ASTHelpers.getType(memberReferenceTree)
: getTypeForSymbol(enclosingSymbol, state);
Type enclosingType = getTypeForSymbol(enclosingSymbol, state);
if (enclosingType == null) {
// we have no additional information from generics, so return NONNULL (presence of a @Nullable
// annotation should have been handled by the caller)
Expand All @@ -894,8 +889,8 @@ public static Nullness getGenericMethodParameterNullness(

/**
* Just like {@link #getGenericMethodParameterNullness(int, Symbol.MethodSymbol, Symbol,
* MemberReferenceTree, VisitorState, Config)}, but takes the enclosing {@code Type} rather than
* the enclosing {@code Symbol}.
* VisitorState, Config)}, but takes the enclosing {@code Type} rather than the enclosing {@code
* Symbol}.
*
* @param parameterIndex index of the parameter
* @param method the generic method
Expand Down
21 changes: 14 additions & 7 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private enum NullMarking {
* class has a mix of annotatedness, depending on presence of {@link
* org.jspecify.annotations.NullMarked} annotations
*/
@SuppressWarnings("JavadocReference")
PARTIALLY_MARKED
}

Expand Down Expand Up @@ -735,13 +736,19 @@ private Description checkParamOverriding(
Nullness.paramHasNullableAnnotation(overriddenMethod, i, config)
? Nullness.NULLABLE
: (config.isJSpecifyMode()
? GenericsChecks.getGenericMethodParameterNullness(
i,
overriddenMethod,
overridingParamSymbols.get(i).owner.owner,
memberReferenceTree,
state,
config)
? (memberReferenceTree != null)
? GenericsChecks.getGenericMethodParameterNullness(
i,
overriddenMethod,
ASTHelpers.getType(memberReferenceTree),
state,
config)
: GenericsChecks.getGenericMethodParameterNullness(
i,
overriddenMethod,
overridingParamSymbols.get(i).owner.owner,
state,
config)
: Nullness.NONNULL);
}
}
Expand Down

0 comments on commit 06d157f

Please sign in to comment.