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 @@ -1178,7 +1178,7 @@ private Type inferCallType(
Type typeAtCallSite = castToNonNull(ASTHelpers.getType(callTree));
if (callTree instanceof MethodInvocationTree) {
Type methodReturnType =
getInferenceExecutableType(callTree, path, state, calledFromDataflow).getReturnType();
getExecutableTypeForInference(callTree, path, state, calledFromDataflow).getReturnType();
return TypeSubstitutionUtils.updateTypeWithInferredNullability(
typeAtCallSite, methodReturnType, typeVarNullability, state, config);
}
Expand Down Expand Up @@ -1243,7 +1243,7 @@ private CallInferenceResult runInferenceForCall(
}
// Store inferred types for lambda or method reference arguments
Type.MethodType callMethodType =
getInferenceExecutableType(callTree, path, state, calledFromDataflow);
getExecutableTypeForInference(callTree, path, state, calledFromDataflow);
new InvocationArguments(callTree, callMethodType)
.forEach(
(argument, argPos, formalParamType, unused) -> {
Expand Down Expand Up @@ -1307,18 +1307,19 @@ private com.sun.tools.javac.util.List<Symbol.TypeVariableSymbol> getCallTypePara
}

/**
* Gets the declaration-site executable type for inference, substituting type arguments from a
* method invocation's receiver and applying any handler-provided models.
* Returns the executable type used to generate inference constraints for {@code callTree}, after
* applying handler-provided models.
*
* <p>Receiver substitution is necessary when an enclosing class type variable appears in the
* method signature. For example, for a method returning {@code T} on a receiver {@code
* Foo<@Nullable Object>}, the invocation return type is {@code @Nullable Object}, not the
* declaration-site type variable {@code T}.
* <p>Type variables whose values are fixed by a method invocation's receiver are substituted. For
* example, for a method returning class type variable {@code T} (for class {@code Foo<T>}) on a
* receiver of type {@code Foo<@Nullable Object>}, the return type is {@code @Nullable Object}.
*
* <p>Unlike {@link #getInvokedMethodTypeAtCall}, this method preserves method type variables so
* inference constraints can be generated for them.
* <p>Type variables being inferred for this call remain unsubstituted so constraints can be
* generated for them. These are method type variables for a generic method invocation and class
* type variables for a diamond constructor. Unlike {@link #getInvokedMethodTypeAtCall}, this
* method does not resolve those variables using an already-computed inference result.
*/
private Type.MethodType getInferenceExecutableType(
private Type.MethodType getExecutableTypeForInference(
ExpressionTree callTree,
@Nullable TreePath path,
VisitorState state,
Expand Down Expand Up @@ -1379,7 +1380,7 @@ private void generateConstraintsForCall(
throws UnsatisfiableConstraintsException {
Symbol.MethodSymbol methodSymbol = getMethodSymbolForCall(callTree);
Type.MethodType methodType =
getInferenceExecutableType(callTree, path, state, calledFromDataflow);
getExecutableTypeForInference(callTree, path, state, calledFromDataflow);
// first, handle the call result flow
if (typeFromAssignmentContext != null) {
Type callResultType =
Expand Down Expand Up @@ -3018,7 +3019,8 @@ private CallAndContext getDirectCallContextForInference(
/**
* Returns the resolved method type at a call site after receiver and inferred type-argument
* substitutions and handler-provided models have been applied. Unlike {@link
* #getInferenceExecutableType}, this method substitutes the method type variables.
* #getExecutableTypeForInference}, this method substitutes the method type variables with
* inferred type arguments.
*/
private Type.MethodType getInvokedMethodTypeAtCall(
Symbol.MethodSymbol methodSymbol,
Expand Down
Loading