Skip to content

Fix VPA crash on defaulted direct supertypes#1810

Open
aosen-xiong wants to merge 9 commits into
eisop:masterfrom
aosen-xiong:vpa-crash
Open

Fix VPA crash on defaulted direct supertypes#1810
aosen-xiong wants to merge 9 commits into
eisop:masterfrom
aosen-xiong:vpa-crash

Conversation

@aosen-xiong

@aosen-xiong aosen-xiong commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Fix #786 by applying computed/default annotations to direct supertypes before viewpoint adaptation.

Direct supertype computation substitutes type variables into supertypes, such as turning Box into Box.

Previously, viewpoint adaptation ran before those substituted supertypes had their default qualifiers applied, so VPA could see an unannotated type argument and crash.

This changes the ordering so direct supertypes are defaulted first, then viewpoint-adapted.

Copilot AI review requested due to automatic review settings June 16, 2026 06:48

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

wmdietl and others added 5 commits June 16, 2026 20:17
…onstruction in SupertypeFinder

Previously, GenericAnnotatedTypeFactory.postDirectSuperTypes iterated over all supertypes of declared types to apply addComputedTypeAnnotations. This hack caused incomplete state when postDirectSuperTypes was overridden, as seen in issue eisop#786 where ViewpointTestChecker crashed during ViewpointAdapter.

By moving the defaulting logic directly into SupertypeFinder (specifically the supertypesFromElement and createEnumSuperType methods that construct types via toAnnotatedType), we ensure every supertype receives its computed defaults precisely once and right at construction time, eliminating the need for the hacky secondary pass.
@wmdietl

wmdietl commented Jul 17, 2026

Copy link
Copy Markdown
Member

@aosen-xiong Can you resolve the merge?

With Antigravity I moved this change into SupertypeFinder, which seems like a better place for this. Do you see any problem with this?

@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl Jul 17, 2026
aosen-xiong and others added 2 commits July 16, 2026 21:46
…ting the enum super type twice on the element path: createEnumSuperType no longer applies computed annotations itself. The element path defaults all supertypes in its trailing loop, and the tree path (which has no such loop) now defaults the enum super type explicitly at its call site.
@aosen-xiong

Copy link
Copy Markdown
Collaborator Author

@aosen-xiong Can you resolve the merge?

With Antigravity I moved this change into SupertypeFinder, which seems like a better place for this. Do you see any problem with this?

I think the approach is good.

The previous approach will call atypeFactory.addComputedTypeAnnotations(..., adt) twice in supertypesFromElement because the createEnumSuperType call it, and the added loop also calls it.

I adjusted the enum handling so its supertype is computed exactly once on both the element and tree paths.

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.

Unexpected null argument when doing VPA

3 participants