Fix VPA crash on defaulted direct supertypes#1810
Open
aosen-xiong wants to merge 9 commits into
Open
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.
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? |
…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.
Collaborator
Author
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.