Use adapted bounds for method/constructor type arguments - #1850
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Checker Framework’s method-invocation type argument checking to use viewpoint-adapted bounds for method type parameters, and adds a viewpoint test to exercise both explicit and inferred method type arguments against those adapted bounds.
Changes:
- Add
AnnotatedTypeFactory.methodTypeVariablesFromUse(...)to compute method type-parameter bounds in the invocation’s viewpoint. - Use the new adapted-bounds helper from
BaseTypeVisitor.visitMethodInvocation(...)when validating method type arguments. - Add a new viewpoint test covering explicit and inferred method type arguments with receiver-dependent bounds.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| framework/tests/viewpointtest/MethodTypeVariableBounds.java | New test cases for receiver-dependent method type parameter bounds under different receiver viewpoints. |
| framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java | Introduces a helper to compute invocation-viewpoint-adapted method type parameter bounds. |
| framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java | Switches method invocation type-argument checking to use adapted bounds from the factory helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aosen-xiong
commented
Jul 6, 2026
AnnotatedTypeCopierWithReplacement skips executable type parameters, so adapted method/constructor type-variable bounds were discarded and inference still saw unadapted declaration bounds. Install the adapted declarations, drop the redundant post-check re-adaptation helper, and add constructor coverage.
wmdietl
requested changes
Jul 16, 2026
…dings (eisop#1886) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
aosen-xiong
added a commit
to aosen-xiong/checker-framework
that referenced
this pull request
Aug 5, 2026
The viewpoint test checker obtained method type parameter bounds through AnnotatedTypeFactory#methodTypeVariablesFromUse, which fetched the raw bounds and then viewpoint-adapted them itself. "Use adapted bounds for method/constructor type arguments" (eisop#1850) performs that adaptation in AbstractViewpointAdapter#viewpointAdaptMethod and #viewpointAdaptConstructor, so the framework method duplicated it. Remove methodTypeVariablesFromUse and its BaseTypeVisitor call site, which restores the master implementation, and read the already-adapted bounds from methodFromUse and constructorFromUse. Constructor invocations are now checked as well; previously only method invocations reported viewpointtest.lost.in.bounds. Update the expectations in the tests added by eisop#1850, and delete ViewpointAdaptationBounds.java, whose cases those tests cover. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #1173.
Use viewpoint-adapted method type parameter bounds when checking method invocation type arguments.
Adds a viewpoint test covering explicit and inferred type arguments.