Skip to content

Handle intersection type in viewpoint adaptation#1434

Open
aosen-xiong wants to merge 16 commits into
eisop:masterfrom
aosen-xiong:eisop-433
Open

Handle intersection type in viewpoint adaptation#1434
aosen-xiong wants to merge 16 commits into
eisop:masterfrom
aosen-xiong:eisop-433

Conversation

@aosen-xiong

@aosen-xiong aosen-xiong commented Oct 28, 2025

Copy link
Copy Markdown
Collaborator

Fixes #433.

Fixes viewpoint adaptation crashes on intersection types.

This PR updates AbstractViewpointAdapter to handle TypeKind.INTERSECTION in 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.

Copilot AI review requested due to automatic review settings March 4, 2026 15:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.INTERSECTION in AbstractViewpointAdapter.combineAnnotationWithType.
  • Handle TypeKind.INTERSECTION in AbstractViewpointAdapter.substituteTVars.
  • Add a viewpointtest regression 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.

Comment thread framework/tests/viewpointtest/IntersectionTypes.java Outdated
@wmdietl

wmdietl commented Mar 21, 2026

Copy link
Copy Markdown
Member

@aosen-xiong Can you look at the Copilot comments and address or resolve them?

@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl Mar 21, 2026
@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong May 24, 2026

@wmdietl wmdietl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread framework/tests/viewpointtest/IntersectionTypes.java Outdated
@aosen-xiong aosen-xiong requested a review from wmdietl May 25, 2026 02:59
@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong May 25, 2026

@wmdietl wmdietl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I tested the vpa on intersection type with class ViewpointAdaptedIntersectionBound.

@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl Jun 8, 2026
@aosen-xiong aosen-xiong requested a review from wmdietl June 11, 2026 04:55
@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong Jun 11, 2026
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.

Viewpoint adaptation crash when adapting intersection type

3 participants