leonard84 opened a new pull request, #2684:
URL: https://github.com/apache/groovy/pull/2684

   This backports the eight decompiler-fidelity fixes from master (#2682, 
commit `4b27025962`) to `GROOVY_5_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`).
   
   **Fixes apply as-is** — all APIs present on 5.0.
   
   **Tests:** `:groovy-console:test` green; `AstNodeToScriptAdapterTest` 71/71 
(validated with a forced `--no-build-cache --rerun-tasks` recompile+run).
   
   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]

Reply via email to