daniellansun commented on code in PR #2784:
URL: https://github.com/apache/groovy/pull/2784#discussion_r3785682216
##########
src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java:
##########
@@ -1020,27 +1021,13 @@ public Expression visitSwitchExprAlt(final
SwitchExprAltContext ctx) {
}
/**
- * <pre>
- * switch(x) {
- * case 0, 1 -> 'a'
- * case 2 -> 'b'
- * default -> 'z'
- * }
- * </pre>
- * will be transformed to:
- * <pre>
- * { ->
- * switch(x) {
- * case 0:
- * case 1: return 'a'
- * case 2: return 'b'
- * default: return 'z'
- * }
- * }.call()
- * </pre>
+ * Builds a first-class {@link SwitchExpression} (GROOVY-12255 / JEP 361).
+ * Arrow arms that are a single expression become {@link YieldStatement}s;
+ * colon arms use explicit {@code yield}. The expression is compiled inline
+ * — it is not rewritten to a closure wrapping a {@link SwitchStatement}.
Review Comment:
Agreed. The method javadoc now only describes what the builder produces (JEP
361, arrow vs colon). The GROOVY-12255 key and the old closure-desugar
narrative were removed from this javadoc (and from the `SwitchExpression` /
`SwitchExpressionWriter` type docs that repeated the same history).
Compatibility notes stay in `COMPATIBILITY.md`.
--
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]