Skip to content

Commit

Permalink
change key of inferredTypes to MethodInvokationTree
Browse files Browse the repository at this point in the history
  • Loading branch information
haewiful committed Feb 22, 2025
1 parent 48bb542 commit 5573800
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class GenericsChecks {
* Any generic type parameter that are not explicitly stated are inferred and cached in this
* field.
*/
private final Map<Tree, Map<Type, Type>> inferredTypes = new HashMap<>();
private final Map<MethodInvocationTree, Map<Type, Type>> inferredTypes = new HashMap<>();

/**
* Checks that for an instantiated generic type, {@code @Nullable} types are only used for type
Expand Down Expand Up @@ -440,7 +440,7 @@ public void checkTypeParameterNullnessForAssignability(
@Nullable Map<Type, Type> genericNullness =
returnType.accept(new InferTypeVisitor(config), lhsType);
if (genericNullness != null) {
inferredTypes.put(rhsTree, genericNullness);
inferredTypes.put(methodInvocationTree, genericNullness);
}
}
}
Expand All @@ -457,9 +457,10 @@ public void checkTypeParameterNullnessForAssignability(

if (rhsType != null && rhsTree instanceof MethodInvocationTree) {
// recreate rhsType using inferred types
Symbol.MethodSymbol methodSymbol = ASTHelpers.getSymbol((MethodInvocationTree) rhsTree);
if (inferredTypes.containsKey(rhsTree)) {
Map<Type, Type> genericNullness = inferredTypes.get(rhsTree);
MethodInvocationTree methodInvocationTree = (MethodInvocationTree) rhsTree;
Symbol.MethodSymbol methodSymbol = ASTHelpers.getSymbol(methodInvocationTree);
if (inferredTypes.containsKey(methodInvocationTree)) {
Map<Type, Type> genericNullness = inferredTypes.get(methodInvocationTree);
com.sun.tools.javac.util.List<Type> from =
com.sun.tools.javac.util.List.from(genericNullness.keySet());
com.sun.tools.javac.util.List<Type> to =
Expand Down

0 comments on commit 5573800

Please sign in to comment.