Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8c40e57
Infer inline generic method references from their argument targets
msridhar Nov 17, 2026
09c66d9
Merge branch 'master' into fix-2063-inline-method-reference
msridhar Nov 18, 2026
04a6cb2
Suppress method reference compatibility errors after inference failure
msridhar Nov 18, 2026
bb3f707
Cover generic method references in diamond constructor calls
msridhar Nov 18, 2026
fb989b7
Cover parameter-driven inference failures for method reference shapes
msridhar Nov 18, 2026
85ea7a8
Document method reference inference outcomes and no-op cases
msridhar Nov 18, 2026
3d65086
Guard method reference inference cache writes
msridhar Nov 18, 2026
9211c9f
Clarify caching of method references with explicit type arguments
msridhar Nov 18, 2026
1496fce
Preserve independent method reference errors after inference failure
msridhar Nov 21, 2026
4a4238b
Document override suppression after method reference inference failure
msridhar Nov 21, 2026
d6fe2b2
Pin inference diagnostics to the failing method reference
msridhar Nov 21, 2026
ebdc5c9
Defer nullness inference failures until constraint collection finishes
msridhar Nov 25, 2026
a9d3e2e
Merge branch 'master' into fix-2063-inline-method-reference
msridhar Nov 25, 2026
2253529
Document which method references share cached inference results
msridhar Nov 25, 2026
c1ba885
Name the inference failure test for dependent compatibility errors
msridhar Nov 25, 2026
ad70eb7
Cover method reference diagnostics in nested generic calls
msridhar Nov 25, 2026
1870428
Use consistent terminology for joint inference
msridhar Nov 25, 2026
2fa91ff
Merge branch 'master' into fix-2063-inline-method-reference
msridhar Nov 26, 2026
0058c3b
fix compile error
msridhar Nov 26, 2026
83554de
Infer later nested calls separately after a contradiction
msridhar Nov 27, 2026
56b63e1
Pin diagnostics for nested calls after an inference failure
msridhar Nov 27, 2026
fca3a91
Document which constraint contradiction the solver reports
msridhar Nov 27, 2026
ae2610c
Share the omitted type argument check for method references
msridhar Nov 27, 2026
ae85b85
Skip nested constraint generation after a contradiction
msridhar Nov 27, 2026
8631d4c
Pin diagnostics for nested calls visited before a contradiction
msridhar Nov 27, 2026
05c7d8d
Check which contradiction generic inference reports
msridhar Nov 28, 2026
5200272
Skip argument type refinement after an inference contradiction
msridhar Nov 28, 2026
180fb69
Tighten the inference work limit for failing call chains
msridhar Nov 28, 2026
6acb8a0
Document when a method reference shares the inference result
msridhar Nov 28, 2026
899008c
restore comment
msridhar Nov 28, 2026
ff887a8
Merge branch 'master' into fix-2063-inline-method-reference
msridhar Dec 1, 2026
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
7 changes: 6 additions & 1 deletion nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,9 @@ public Description matchMemberReference(MemberReferenceTree tree, VisitorState s
* @param memberReferenceTree if override is via a method reference, the relevant {@link
* MemberReferenceTree}; otherwise {@code null}
* @param state visitor state.
* @return discovered error, or {@link Description#NO_MATCH} if no error
* @return discovered error, or {@link Description#NO_MATCH} if no error is found or a method
* reference's inference failure has already been reported, as determined by {@link
* GenericsChecks#hasReportedInferenceFailure(MemberReferenceTree)}
*/
private Description checkOverriding(
Symbol.MethodSymbol overriddenMethod,
Expand All @@ -1590,6 +1592,9 @@ private Description checkOverriding(
VisitorState state) {
ResolvedMethodReference resolvedReference = null;
if (memberReferenceTree != null) {
if (genericsChecks.hasReportedInferenceFailure(memberReferenceTree)) {
return Description.NO_MATCH;
}
Comment thread
vlsi marked this conversation as resolved.
Resolved
Type functionalInterfaceType = genericsChecks.getPolyExpressionType(memberReferenceTree);
if (functionalInterfaceType != null) { // diff-coverage: ignore -- Unattributed javac tree.
resolvedReference =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ record InferenceVariable(Element typeVariable, Tree site) {}
Map<Element, Type.TypeVar> registerInferenceVariables(
Tree site, List<? extends Element> typeVariables);

/**
* Returns whether {@code type}, including its nested types and bounds, mentions a fresh type
* variable registered with this solver. Fresh variables from other inference problems are fixed
* types for this query.
*/
boolean containsInferenceVariable(Type type);

/**
* Exception thrown when the constraints added to the solver are determined to be unsatisfiable.
*
Expand Down Expand Up @@ -87,15 +94,21 @@ public boolean isCausedByNonNullUpperBound() {
* must appear in the types as the fresh type variables returned by {@link
* #registerInferenceVariables(Tree, List)}.
*
* <p>The solver records the first contradiction detected while adding constraints and ignores
* subsequent constraints. {@link #solve()} throws the recorded contradiction.
*
* @param subtype the subtype
* @param supertype the supertype
* @param localVariableType whether this constraint arises from assigning to a local variable. In
* such a case, the top-level types are not constrained to be subtypes (as local variable
* types are separately inferred), but the nested types are still constrained.
* @throws UnsatisfiableConstraintsException if the constraints are determined to be unsatisfiable
*/
void addSubtypeConstraint(Type subtype, Type supertype, boolean localVariableType)
throws UnsatisfiableConstraintsException;
void addSubtypeConstraint(Type subtype, Type supertype, boolean localVariableType);

/**
* Returns whether adding a constraint detected a contradiction that {@link #solve()} will report.
*/
boolean hasDeferredFailure();

enum InferredNullability {
NONNULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class ConstraintSolverImpl implements ConstraintSolver {
private final Config config;
private final Handler handler;
private final VisitorState state;
private @Nullable UnsatisfiableConstraintsException deferredFailure;

/**
* Maps the symbol of each fresh type variable created by {@link #registerInferenceVariables(Tree,
Expand Down Expand Up @@ -124,9 +125,29 @@ public Map<Element, Type.TypeVar> registerInferenceVariables(
}

@Override
public void addSubtypeConstraint(Type subtype, Type supertype, boolean localVariableType)
throws UnsatisfiableConstraintsException {
subtype.accept(new AddSubtypeConstraintsVisitor(localVariableType), supertype);
public boolean containsInferenceVariable(Type type) {
TypeVarWithSymbolCollector collector =
new TypeVarWithSymbolCollector(inferenceVariables::containsKey);
type.accept(collector, null);
return !collector.getMatches().isEmpty();
}

@Override
public void addSubtypeConstraint(Type subtype, Type supertype, boolean localVariableType) {
if (deferredFailure != null) {
return;
}
Comment thread
vlsi marked this conversation as resolved.
Resolved
try {
subtype.accept(new AddSubtypeConstraintsVisitor(localVariableType), supertype);
} catch (UnsatisfiableConstraintsException e) {
// Let constraint generation finish registering method references that share this result.
deferredFailure = e;
}
}
Comment thread
vlsi marked this conversation as resolved.
Resolved

@Override
public boolean hasDeferredFailure() {
return deferredFailure != null;
}

class AddSubtypeConstraintsVisitor extends Types.DefaultTypeVisitor<@Nullable Void, Type> {
Expand Down Expand Up @@ -354,6 +375,9 @@ private void constrainWildcardToSupertype(WildcardType subtypeWildcard, Type sup
@Override
public Map<InferenceVariable, InferredNullability> solve()
throws UnsatisfiableConstraintsException {
if (deferredFailure != null) {
throw deferredFailure;
}
/* ---------- work-list propagation of nullability ---------- */
Deque<InferenceVariable> work = new ArrayDeque<>();
vars.forEach(
Expand Down
Loading
Loading