Skip to content

Commit 676b89c

Browse files
committed
improved comments
1 parent 44b0e75 commit 676b89c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,17 @@ private Type inferGenericMethodCallType(
528528
}
529529
}
530530
// we get the return type of the method call with inferred nullability of type variables
531-
// substituted in.
532-
// then, we apply those nullability annotations to the return type at the call site
533-
// TODO optimize this to avoid doing so many substitutions in the future, if needed
531+
// substituted in. So, if the method returns List<T>, and we inferred T to be nullable, then
532+
// methodReturnTypeWithInferredNullability will be List<@Nullable T>.
534533
Type methodReturnTypeWithInferredNullability =
535534
getTypeWithInferredNullability(
536535
state, config, ((Type.ForAll) type).qtype, typeVarNullability)
537536
.getReturnType();
538537
Type returnTypeAtCallSite = castToNonNull(ASTHelpers.getType(invocationTree));
538+
// then, we apply those nullability annotations to the return type at the call site.
539+
// So, continuing the above example, if javac inferred the type of the call to be List<String>,
540+
// we will return List<@Nullable String>, correcting its nullability based on our own inference.
541+
// TODO optimize the above steps to avoid doing so many substitutions in the future, if needed
539542
return TypeSubstitutionUtils.restoreExplicitNullabilityAnnotations(
540543
methodReturnTypeWithInferredNullability,
541544
returnTypeAtCallSite,

0 commit comments

Comments
 (0)