test(java): pin enum constants surviving alongside enum methods - #1771
Merged
Conversation
Java enum methods already resolve on main: find_class_member_body descends into enum_body_declarations (Java-gated) while find_class_body keeps returning enum_body, which is what extract_enum_members needs to reach the constants — they are siblings of enum_body_declarations, not children. That distinction was unguarded. java_enum_dedup_preserves_calls_issue1234 asserted the methods and the absence of duplicate Function defs, but never asserted the constants, so collapsing the two lookups would have passed the suite while silently dropping every enum constant from the graph. PR #984 proposed exactly that collapse — redirecting the shared find_class_body — which is what surfaced the gap. Verified binding: pointing extract_enum_members at find_class_member_body reddens the new Variable assertions and nothing else. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> Co-authored-by: sahil-mangla <manglasahil2017@gmail.com>
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.
Closes the gap that #984 by @sahil-mangla exposed. Credited via
Co-authored-by.The feature already works
Java enum methods resolve correctly on
maintoday:find_class_member_bodydescends intoenum_body_declarations(Java-gated) whilefind_class_bodykeeps returningenum_body, which is whatextract_enum_membersneeds to reach the constants — they are siblings ofenum_body_declarations, not children. I verified that empirically with a probe asserting the enum label, its methods and its constants together; it passes unmodified.But the distinction was unguarded
java_enum_dedup_preserves_calls_issue1234asserted the methods and the absence of duplicateFunctiondefs — but never asserted the constants. So collapsing those two lookups into one would have passed the entire suite while silently dropping every enum constant from the graph.That is exactly what #984 proposed: redirecting the shared
find_class_body. Its ownMethodassertion would have gone green, and the loss would have shipped invisibly.The guard
Two assertions added to the existing test rather than a near-duplicate test, since the fixture already has the right shape.
Verified binding: pointing
extract_enum_membersatfind_class_member_body— the collapse #984 proposed — reddens exactly the newVariableassertions and nothing else.The comment at the assertions names why the two lookups differ, so the next person to touch enum extraction finds the reasoning rather than rediscovering it through a silent regression.