RFR: 8334248: Invalid error for early construction local class constructor method reference [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jun 14 21:31:21 UTC 2024


On Fri, 14 Jun 2024 21:10:51 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> I think it is the same issue. Attr::visitNewClass has code that is 1-1 with the one you have in this fix. The only difference between the method reference code and the new code is the presence of that additional enclosing instance check (the correctness of which I'm also not sure) when the method reference is being resolved, as I explained earlier. If that check wasn't there the two programs would fail in exactly the same way.

As far as I can tell, that additional check for method reference is there "only" to generate a better error message. And, in fact, the check in Resolve dominates the one in Attr: even if the check you tweaked in this PR is commented out completely, no regression test fails.

Apparently the Attr check was added here:
https://bugs.openjdk.org/browse/JDK-8173456

As far as I can tell, the only reason the check was added was to issue an error in cases like `super(V::new)`, which sounds familiar. In other words, instead of enhancing the existing check in `Resolve` (the one above), we ended up adding another one. 

Ideally we should only keep the check in Resolve (as that generates a better error), but augment it so that it detects the issue described in 8173456.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19705#issuecomment-2168784820


More information about the compiler-dev mailing list