-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make GenericsChecks methods static #805
Make GenericsChecks methods static #805
Conversation
…with generic @nullable return type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc nits only, but quite a few of them...
public void checkTypeParameterNullnessForFunctionReturnType( | ||
ExpressionTree retExpr, Symbol.MethodSymbol methodSymbol) { | ||
if (!config.isJSpecifyMode()) { | ||
public static void checkTypeParameterNullnessForFunctionReturnType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a public method, so... javadoc?
@@ -237,7 +239,7 @@ private void reportInvalidOverridingMethodParamTypeError( | |||
* @return Type of the tree with preserved annotations. | |||
*/ | |||
@Nullable | |||
private Type getTreeType(Tree tree) { | |||
private static Type getTreeType(Tree tree, VisitorState state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -267,8 +269,9 @@ private Type getTreeType(Tree tree) { | |||
* @param tree the tree to check, which must be either an {@link AssignmentTree} or a {@link | |||
* VariableTree} | |||
*/ | |||
public void checkTypeParameterNullnessForAssignability(Tree tree) { | |||
if (!config.isJSpecifyMode()) { | |||
public static void checkTypeParameterNullnessForAssignability( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -334,7 +340,8 @@ public void checkTypeParameterNullnessForFunctionReturnType( | |||
* @param lhsType type for the lhs of the assignment | |||
* @param rhsType type for the rhs of the assignment | |||
*/ | |||
private boolean compareNullabilityAnnotations(Type.ClassType lhsType, Type.ClassType rhsType) { | |||
private static boolean compareNullabilityAnnotations( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -395,7 +402,8 @@ private boolean compareNullabilityAnnotations(Type.ClassType lhsType, Type.Class | |||
* @param tree A parameterized typed tree for which we need class type with preserved annotations. | |||
* @return A Type with preserved annotations. | |||
*/ | |||
private Type.ClassType typeWithPreservedAnnotations(ParameterizedTypeTree tree) { | |||
private static Type.ClassType typeWithPreservedAnnotations( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -686,15 +704,20 @@ public static Nullness getGenericReturnNullnessAtInvocation( | |||
* @return Nullness of parameter at {@code paramIndex}, or {@code NONNULL} if the call does not | |||
* invoke an instance method | |||
*/ | |||
public Nullness getGenericParameterNullnessAtInvocation( | |||
int paramIndex, Symbol.MethodSymbol invokedMethodSymbol, MethodInvocationTree tree) { | |||
public static Nullness getGenericParameterNullnessAtInvocation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -726,8 +749,12 @@ public Nullness getGenericParameterNullnessAtInvocation( | |||
* @return nullability of the relevant parameter type of {@code method} in the context of {@code | |||
* enclosingType} | |||
*/ | |||
public Nullness getGenericMethodParameterNullness( | |||
int parameterIndex, Symbol.MethodSymbol method, Type enclosingType) { | |||
public static Nullness getGenericMethodParameterNullness( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -741,8 +768,8 @@ public Nullness getGenericMethodParameterNullness( | |||
* @param tree tree for overriding method | |||
* @param overriddenMethodType type of the overridden method | |||
*/ | |||
private void checkTypeParameterNullnessForOverridingMethodParameterType( | |||
MethodTree tree, Type overriddenMethodType) { | |||
private static void checkTypeParameterNullnessForOverridingMethodParameterType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -771,18 +801,20 @@ private void checkTypeParameterNullnessForOverridingMethodParameterType( | |||
* @param tree tree for overriding method | |||
* @param overriddenMethodType type of the overridden method | |||
*/ | |||
private void checkTypeParameterNullnessForOverridingMethodReturnType( | |||
MethodTree tree, Type overriddenMethodType) { | |||
private static void checkTypeParameterNullnessForOverridingMethodReturnType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc needs to be updated with the new @param
s.
@@ -2414,6 +2413,10 @@ public ErrorBuilder getErrorBuilder() { | |||
return errorBuilder; | |||
} | |||
|
|||
public Config getConfig() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if this is unbelievably pedantic but: public method -> javadoc 😅 (Also, as a getter, maybe worth moving further up within this file? Closer to the field unless that breaks GJF rules?)
Thanks for helping keep our docs in a decent shape 🙂 @lazaroclapp this is ready for another look when you can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Previously, some methods in
GenericsChecks
were static methods and some were instance methods. We did not get much of any benefit from the instance methods, as it would be painful to create a singleGenericsChecks
object and thread it everywhere it is needed. So, this PR just converts allGenericsChecks
methods to be static and passes parameters as needed (which isn't too painful).