Handle intersection type in viewpoint adaptation#1434
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a Checker Framework crash (#433) when viewpoint adaptation encounters intersection types by adapting each bound of an INTERSECTION type and adds a regression test.
Changes:
- Handle
TypeKind.INTERSECTIONinAbstractViewpointAdapter.combineAnnotationWithType. - Handle
TypeKind.INTERSECTIONinAbstractViewpointAdapter.substituteTVars. - Add a
viewpointtestregression test for intersection-type adaptation and update the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| framework/tests/viewpointtest/IntersectionTypes.java | Adds regression test coverage for intersection-type viewpoint adaptation. |
| framework/src/main/java/org/checkerframework/framework/type/AbstractViewpointAdapter.java | Adds intersection-type handling during viewpoint adaptation and type-variable substitution. |
| docs/CHANGELOG.md | Notes the closed issue (#433). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@aosen-xiong Can you look at the Copilot comments and address or resolve them? |
wmdietl
left a comment
There was a problem hiding this comment.
The shared logic looks much better.
The test case still doesn't seem to exercise VP adaptation of the intersection bounds.
|
|
||
| // TODO: Re-enable after deciding the expected behavior for mixed explicit annotations on | ||
| // intersection bounds. See https://github.com/eisop/checker-framework/issues/1735. | ||
| // <T extends @A Foo & @B Bar> void callAnnotatedBounds(T p) {} |
There was a problem hiding this comment.
So after the discussion from 1735 we said there can only be one annotated bound in an intersection type.
Am I missing a test case that exercises an intersection bound that needs to be VP adapted? That would still be convincing to show that VP is doing something. The test case with multiple different annotations can stay at the end, highlighting what the current decision about 1735 is.
There was a problem hiding this comment.
Okay, I tested the vpa on intersection type with class ViewpointAdaptedIntersectionBound.
…stractViewpointAdapter.java Co-authored-by: Werner Dietl <wdietl@gmail.com>
Fixes #433.
Fixes viewpoint adaptation crashes on intersection types.
This PR updates
AbstractViewpointAdapterto handleTypeKind.INTERSECTIONin both viewpoint adaptation and type-variable substitution. Intersection bounds are adapted/substituted individually, then the intersection type’s primary annotations are recomputed from the updated bounds.