GROOVY-12144: Fix AstNodeToScriptAdapter decompiler rendering fidelity (GROOVY_4_0_X backport)#2685
Merged
daniellansun merged 1 commit intoJul 11, 2026
Conversation
GROOVY_4_0_X backport of master commit 4b27025. AstNodeToScriptVisitor rendered several constructs incorrectly, producing source that did not round-trip. Applies the eight independent visitor-method fixes and their regression tests (nested generics, exclusive range bounds, Elvis, attribute access, explicit zero-arg closure arrow, safe index access, numeric literal suffixes, explicit method-call type arguments). Assisted-by: Claude Code (Opus 4.8)
Contributor
|
Merged. Thanks. |
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.
This backports the eight decompiler-fidelity fixes from master (#2682, commit
4b27025962) toGROOVY_4_0_X.AstNodeToScriptVisitorrendered several constructs so they did not round-trip; each fix is localized to one visitor method:Map<String, List<Integer>>→Map<String, List>) —visitGenericsrecurses into concrete args.visitRangeExpression.c ?: d→c ? c : d, evaluatingctwice) —visitShortTernaryExpressionemits?:.obj.@f→obj.f) —visitPropertyExpressionemits.@for anAttributeExpression.{ -> ... }→{ ... }) —visitClosureExpressiondistinguishes a null parameter list fromParameter.EMPTY_ARRAY.list?[0]→list[0]) —visitBinaryExpression.42L/2.5f/3.5d/10G) —visitConstantExpressionre-appendsL/F/D/G.Collections.<String>emptyList()) —visitMethodCallExpression.One regression test per defect (GroovyTestCase style, matching the existing test class). Existing tests reconciled to the corrected output:
testTernaryOperaters(elvis),testGenericsInMethods(nested generics now preserved),testLogAnnotation(@Log'sLevel.FINEis anAttributeExpression, now rendersLevel.@FINE).Branch adaptation (fix 6): on 4.0 the safe-index operator carries its own
?[operation text (the file has drifted from master), sovisitBinaryExpression'"'"'s subscript detection was widened to recognise?[and emit?[/[perisSafe(). Verified to round-trip.Tests:
AstNodeToScriptAdapterTest71/71 (forced recompile+run). Whole-module has 3 pre-existingSwingBuilderConsoleTestGUI failures unrelated to this change (confirmed against the untouched baseline).Master PR: #2682
🤖 Prepared with Claude Code (Opus 4.8) on behalf of @leonard84.