Fix VPA crash on defaulted direct supertypes, optimize - #1810
Conversation
…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.
|
@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? |
…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.
I think the approach is good. The previous approach will call I adjusted the enum handling so its supertype is computed exactly once on both the element and tree paths. |
|
I have pushed two follow-up commits to this PR:
Let me know if you have any questions! |
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.