paulk-asert commented on PR #3009: URL: https://github.com/apache/groovy/pull/3009#issuecomment-6489752895
Thanks Daniel, I've pushed b361b9ac35 to cover your points: 1. **Placement.** The new `earlyYieldInSwitchExpressionPositions` test pins early `yield` in `return switch …`, an assignment RHS and a method argument, both dynamically and under `@CompileStatic`. These are expression positions, so they go through the switch-expression path and were never affected. I also probed the early yield in trailing position directly, inside `if`, `try`/`finally`, `synchronized`, a closure, under `@CompileStatic`, and with a typed `String` return. All are correct with this PR. 6.0.0 returns the late value in all of those trailing positions, and 5.1.3 gets them all right. `return`/`break` inside a value-producing switch are still rejected. 2. **`finally`.** Covered by `earlyYieldRunsEnclosingFinallyBlock`. 3. **#2933 / #3003.** #3003 has landed. I ran a combined smoke test before it merged: arrow arms that narrow with `case String ->` and yield early, plus `break`/`continue`/`return` from arrow arms in a loop, all under `@TypeChecked`. With both changes applied, it passed along with both PRs' tests and the stc package (3,676 tests). #2933 is still open, so I'll do the same when it's ready. 4. **`ReturnAdder` shape match.** Good call. The lowered block is now marked itself, not just its `break`. `ReturnAdder` finds the block by that marker and replaces only its trailing value and `break`, so statements another transform adds earlier in the block are kept. `earlyYieldInReturnPositionKeepsStatementsAddedBeforeIt` uses a customizer to insert a statement at `CANONICALIZATION`. With the previous shape match, `pick(true)` silently returned `null`; now it returns `'first'`. If a marked block ever stops ending with its value and `break`, it fails with a `GroovyBugError` instead of compiling the wrong result. Locally the groovy, bugs, gls, classgen, control and parser suites pass (12,939 tests) and lintGate is clean. The commits also cherry-pick cleanly onto GROOVY_6_0_X for 6.0.1. -- 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]
