RFR: 8341782: Allow lambda capture of basic for() loop variables as with enhanced for()
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Oct 9 21:27:13 UTC 2024
On Wed, 9 Oct 2024 21:19:09 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> So I'm not sure - it seems to me `letInit` should happily remove flags for any variable it sees marked with `FOR_LOOP_BODY_MAY_CAPTURE` (as that is surely a variable of a for loop and we must be in that loop's body for the variable to have that flag set?)
Concretely, why not, in `letInit`:
// In basic for() loop bodies, variables that are reassigned can no longer be captured
if ((sym.flags_field & FOR_LOOP_BODY_MAY_CAPTURE) != 0 && !uninits.isMember(sym.adr)) {
sym.flags_field &= ~FOR_LOOP_BODY_MAY_CAPTURE;
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21415#discussion_r1794246067
More information about the compiler-dev
mailing list