Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@
public final class GenericsChecks {

/** Marker interface for results of attempting to infer nullability of type variables at a call */
private interface MethodInferenceResult {}
private interface CallInferenceResult {}

/**
* Indicates successful inference of nullability of type variables at a call. Stores the inferred
* type variable nullability.
*/
private record InferenceSuccess(
Map<Element, ConstraintSolver.InferredNullability> typeVarNullability)
implements MethodInferenceResult {}
implements CallInferenceResult {}

/** Indicates failed inference of nullability of type variables at a call */
private record InferenceFailure(@SuppressWarnings("UnusedVariable") @Nullable String errorMessage)
implements MethodInferenceResult {
implements CallInferenceResult {
private InferenceFailure(@Nullable String errorMessage) {
this.errorMessage = errorMessage;
}
Expand All @@ -101,7 +101,7 @@ private InferenceFailure(@Nullable String errorMessage) {
* its type argument nullability. The call must not have any explicit type arguments. If a tree is
* not present as a key in this map, it means inference has not yet been attempted for that call.
*/
private final Map<MethodInvocationTree, MethodInferenceResult>
private final Map<MethodInvocationTree, CallInferenceResult>
inferredTypeVarNullabilityForGenericCalls = new LinkedHashMap<>();

/**
Expand Down Expand Up @@ -1177,7 +1177,7 @@ private Type inferGenericMethodCallType(
Verify.verify(isGenericCallNeedingInference(invocationTree));
Symbol.MethodSymbol methodSymbol = ASTHelpers.getSymbol(invocationTree);
Map<Element, ConstraintSolver.InferredNullability> typeVarNullability = null;
MethodInferenceResult result = inferredTypeVarNullabilityForGenericCalls.get(invocationTree);
CallInferenceResult result = inferredTypeVarNullabilityForGenericCalls.get(invocationTree);
if (result == null) { // have not yet attempted inference for this call
result =
runInferenceForCall(
Expand Down Expand Up @@ -1215,7 +1215,7 @@ private Type inferGenericMethodCallType(
* @return the inference result, either success with inferred type variable nullability or failure
* with an error message
*/
private MethodInferenceResult runInferenceForCall(
private CallInferenceResult runInferenceForCall(
VisitorState state,
@Nullable TreePath path,
MethodInvocationTree invocationTree,
Expand Down Expand Up @@ -2376,7 +2376,7 @@ private Type.MethodType getInferredMethodTypeForGenericMethodReference(
Tree parentTree = parentPath != null ? parentPath.getLeaf() : null;
if (parentTree instanceof MethodInvocationTree methodInvocationTree
&& isGenericCallNeedingInference(methodInvocationTree)) {
MethodInferenceResult inferenceResult =
CallInferenceResult inferenceResult =
inferredTypeVarNullabilityForGenericCalls.get(methodInvocationTree);
if (inferenceResult instanceof InferenceSuccess successResult) {
return TypeSubstitutionUtils.updateMethodTypeWithInferredNullability(
Expand Down Expand Up @@ -2613,7 +2613,7 @@ private Type substituteTypeArgsInGenericMethodType(

// There are no explicit type arguments, so use the inferred types
if (explicitTypeArgs.isEmpty() && tree instanceof MethodInvocationTree invocationTree) {
MethodInferenceResult result = inferredTypeVarNullabilityForGenericCalls.get(tree);
CallInferenceResult result = inferredTypeVarNullabilityForGenericCalls.get(tree);
if (result == null) {
// have not yet attempted inference for this call
InvocationAndContext invocationAndType =
Expand Down
Loading