@@ -1178,7 +1178,7 @@ private Type inferCallType(
11781178 Type typeAtCallSite = castToNonNull (ASTHelpers .getType (callTree ));
11791179 if (callTree instanceof MethodInvocationTree ) {
11801180 Type methodReturnType =
1181- getInferenceExecutableType (callTree , path , state , calledFromDataflow ).getReturnType ();
1181+ getExecutableTypeForInference (callTree , path , state , calledFromDataflow ).getReturnType ();
11821182 return TypeSubstitutionUtils .updateTypeWithInferredNullability (
11831183 typeAtCallSite , methodReturnType , typeVarNullability , state , config );
11841184 }
@@ -1243,7 +1243,7 @@ private CallInferenceResult runInferenceForCall(
12431243 }
12441244 // Store inferred types for lambda or method reference arguments
12451245 Type .MethodType callMethodType =
1246- getInferenceExecutableType (callTree , path , state , calledFromDataflow );
1246+ getExecutableTypeForInference (callTree , path , state , calledFromDataflow );
12471247 new InvocationArguments (callTree , callMethodType )
12481248 .forEach (
12491249 (argument , argPos , formalParamType , unused ) -> {
@@ -1307,18 +1307,19 @@ private com.sun.tools.javac.util.List<Symbol.TypeVariableSymbol> getCallTypePara
13071307 }
13081308
13091309 /**
1310- * Gets the declaration-site executable type for inference, substituting type arguments from a
1311- * method invocation's receiver and applying any handler-provided models.
1310+ * Returns the executable type used to generate inference constraints for {@code callTree}, after
1311+ * applying handler-provided models.
13121312 *
1313- * <p>Receiver substitution is necessary when an enclosing class type variable appears in the
1314- * method signature. For example, for a method returning {@code T} on a receiver {@code
1315- * Foo<@Nullable Object>}, the invocation return type is {@code @Nullable Object}, not the
1316- * declaration-site type variable {@code T}.
1313+ * <p>Type variables whose values are fixed by a method invocation's receiver are substituted. For
1314+ * example, for a method returning class type variable {@code T} (for class {@code Foo<T>}) on a
1315+ * receiver of type {@code Foo<@Nullable Object>}, the return type is {@code @Nullable Object}.
13171316 *
1318- * <p>Unlike {@link #getInvokedMethodTypeAtCall}, this method preserves method type variables so
1319- * inference constraints can be generated for them.
1317+ * <p>Type variables being inferred for this call remain unsubstituted so constraints can be
1318+ * generated for them. These are method type variables for a generic method invocation and class
1319+ * type variables for a diamond constructor. Unlike {@link #getInvokedMethodTypeAtCall}, this
1320+ * method does not resolve those variables using an already-computed inference result.
13201321 */
1321- private Type .MethodType getInferenceExecutableType (
1322+ private Type .MethodType getExecutableTypeForInference (
13221323 ExpressionTree callTree ,
13231324 @ Nullable TreePath path ,
13241325 VisitorState state ,
@@ -1379,7 +1380,7 @@ private void generateConstraintsForCall(
13791380 throws UnsatisfiableConstraintsException {
13801381 Symbol .MethodSymbol methodSymbol = getMethodSymbolForCall (callTree );
13811382 Type .MethodType methodType =
1382- getInferenceExecutableType (callTree , path , state , calledFromDataflow );
1383+ getExecutableTypeForInference (callTree , path , state , calledFromDataflow );
13831384 // first, handle the call result flow
13841385 if (typeFromAssignmentContext != null ) {
13851386 Type callResultType =
@@ -3018,7 +3019,8 @@ private CallAndContext getDirectCallContextForInference(
30183019 /**
30193020 * Returns the resolved method type at a call site after receiver and inferred type-argument
30203021 * substitutions and handler-provided models have been applied. Unlike {@link
3021- * #getInferenceExecutableType}, this method substitutes the method type variables.
3022+ * #getExecutableTypeForInference}, this method substitutes the method type variables with
3023+ * inferred type arguments.
30223024 */
30233025 private Type .MethodType getInvokedMethodTypeAtCall (
30243026 Symbol .MethodSymbol methodSymbol ,
0 commit comments