Skip to content

Fix problem with type var in a method reference#7729

Open
smillst wants to merge 3 commits into
typetools:masterfrom
smillst:issue7680
Open

Fix problem with type var in a method reference#7729
smillst wants to merge 3 commits into
typetools:masterfrom
smillst:issue7680

Conversation

@smillst
Copy link
Copy Markdown
Member

@smillst smillst commented May 18, 2026

Fixes #7680.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4197d273-d6a8-4e00-b6e1-37a04801c3c2

📥 Commits

Reviewing files that changed from the base of the PR and between f98af3e and aefd9c3.

📒 Files selected for processing (6)
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/InvocationTypeInference.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InvocationType.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/MethodReferenceType.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/MethodType.java
  • framework/tests/all-systems/Issue7680.java

📝 Walkthrough

Walkthrough

This PR refactors Java 8 type inference to use a class hierarchy for invocation type handling. InvocationType becomes an abstract base class with an abstract getReturnType method, shifting return-type computation to two new subclasses: MethodType for method and constructor invocations (handling diamond inference), and MethodReferenceType for method references (handling receiver binding and varargs expansion). Factory methods in InferenceFactory and the invocation-site instantiation in InvocationTypeInference are updated to construct the appropriate specialized subclass. A test case for Issue #7680 is included.

Possibly related PRs

  • typetools/checker-framework#7545: Modifies method-reference receiver type computation in InferenceFactory after compile-time declaration type is computed.
  • typetools/checker-framework#7718: Fixes InvocationType.getParameterTypes(...) for varargs and parameter-list construction, directly connected at the invocation-parameter inference level.

Suggested reviewers

  • mernst
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The pull request makes substantial refactoring changes to the type inference framework by introducing MethodType and MethodReferenceType subclasses and converting InvocationType to an abstract base class, but does not directly address the StructuralEqualityComparer crash mechanism identified in issue #7680. Verify whether the architectural changes (MethodType/MethodReferenceType subclassing) indirectly resolve the type variable/declared type comparison issue by ensuring correct type representations are used during inference, or if additional changes to StructuralEqualityComparer/DefaultTypeHierarchy are needed.
✅ Passed checks (1 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed All changes align with refactoring the type inference framework to use more specific subclasses (MethodType, MethodReferenceType) instead of generic InvocationType, which is in scope for addressing method-reference type handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StructuralEqualityComparer: unexpected combination

2 participants