On Thu, 28 May 2026 21:17:37 GMT, Maurizio Cimadamore <[email protected]> wrote:
> This PR tidies up the DA/DU logic for strict field initialization. > The main idea is to revisit the changes around `forEachInitializer`, so that > the method now accepts a predicate. > Four predicates are defined: > * one that selects all static initializers > * one that selects early instance initializers > * one that selects late instance initializers > * one that selects all instance initializers > > Then all calls to `forEachInitializer` are rewired to use the correct > predicate. The resulting code is a bit more declarative and easier to follow. > > The main change is that the call to `forEachInitializer` with early instance > predicate is moved from `visitApply` to `visitMethod`. > In other words, to follow the spec correctly, DA/DU state for early > initializers must be processed _before_ the first statement in a constructor > body that contains a super call. > > This reveals issues in the tests which have been fixed. I have also added a > new test that should pass, but was rejected. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). lgtm ------------- Marked as reviewed by vromero (Committer). PR Review: https://git.openjdk.org/valhalla/pull/2484#pullrequestreview-4391500665
