Skip to content

Fix VPA crash on defaulted direct supertypes, optimize - #1810

Merged
wmdietl merged 15 commits into
eisop:masterfrom
aosen-xiong:vpa-crash
Aug 27, 2026
Merged

Fix VPA crash on defaulted direct supertypes, optimize#1810
wmdietl merged 15 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.

@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong Jul 25, 2026
@wmdietl

wmdietl commented Aug 27, 2026

Copy link
Copy Markdown
Member

I have pushed two follow-up commits to this PR:

  1. Resolved the CHANGELOG.md conflict: Integrated both eisop#786 and eisop#1965 into the closed issues list.
  2. Optimized SupertypeFinder to avoid re-defaulting Object: The initial PR logic safely defaults Object, but because Object was sourced from toAnnotatedType(superClass, false), it created an undefaulted Object which then had addComputedTypeAnnotations redundantly applied to it over and over for every generic parameterization (as tracked by directSupertypesCache). I updated the logic to always use AnnotatedTypeMirror.createTypeOfObject(atypeFactory) instead, which hits the elementCache and is already pre-defaulted. We then bypass the addComputedTypeAnnotations trailing loop for Object, entirely eliminating the redundant processing noted in performance-notes.md.

Let me know if you have any questions!

@wmdietl wmdietl changed the title Fix VPA crash on defaulted direct supertypes Fix VPA crash on defaulted direct supertypes, optimize Aug 27, 2026
@wmdietl
wmdietl enabled auto-merge (squash) August 27, 2026 20:47
@wmdietl
wmdietl merged commit dcbb9e7 into eisop:master Aug 27, 2026
44 checks passed
@aosen-xiong
aosen-xiong deleted the vpa-crash branch August 27, 2026 22:05
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