leonard84 opened a new pull request, #2685:
URL: https://github.com/apache/groovy/pull/2685
This backports the eight decompiler-fidelity fixes from master (#2682,
commit `4b27025962`) to `GROOVY_4_0_X`. `AstNodeToScriptVisitor` rendered
several constructs so they did not round-trip; each fix is localized to one
visitor method:
1. Nested generic type arguments dropped (`Map<String, List<Integer>>` →
`Map<String, List>`) — `visitGenerics` recurses into concrete args.
2. Range bound exclusions dropped — `visitRangeExpression`.
3. Elvis rendered as a duplicated ternary (`c ?: d` → `c ? c : d`,
evaluating `c` twice) — `visitShortTernaryExpression` emits `?:`.
4. Attribute access lost the at-sign (`obj.@f` → `obj.f`) —
`visitPropertyExpression` emits `.@` for an `AttributeExpression`.
5. Explicit zero-arg closures lost the arrow (`{ -> ... }` → `{ ... }`) —
`visitClosureExpression` distinguishes a null parameter list from
`Parameter.EMPTY_ARRAY`.
6. Safe index access lost safe navigation (`list?[0]` → `list[0]`) —
`visitBinaryExpression`.
7. Numeric literal type suffixes dropped (`42L/2.5f/3.5d/10G`) —
`visitConstantExpression` re-appends `L/F/D/G`.
8. Explicit method-call type arguments dropped
(`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`'s `Level.FINE` is an
`AttributeExpression`, now renders `Level.@FINE`).
**Branch adaptation (fix 6):** on 4.0 the safe-index operator carries its
own `?[` operation text (the file has drifted from master), so
`visitBinaryExpression`'"'"'s subscript detection was widened to recognise `?[`
and emit `?[`/`[` per `isSafe()`. Verified to round-trip.
**Tests:** `AstNodeToScriptAdapterTest` 71/71 (forced recompile+run).
Whole-module has 3 pre-existing `SwingBuilderConsoleTest` GUI failures
unrelated to this change (confirmed against the untouched baseline).
Master PR: https://github.com/apache/groovy/pull/2682
---
🤖 Prepared with Claude Code (Opus 4.8) on behalf of @leonard84.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]