RFR: 8274347: Passing a *nested* switch expression as a parameter causes an NPE during compile

Vicente Romero vromero at openjdk.java.net
Wed Oct 6 15:56:09 UTC 2021


On Wed, 6 Oct 2021 09:04:59 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> Switch handling needs to compute if a case's statements complete normally or not (this is used on multiple places later in the pipeline). But, especially during speculative attributions, the tree may not be fully attributed. `preFlow` should be invoked before invoking flow. The patch also fixes binding pattern handling in preFlow/postAttr.

looks sensible to me

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1803:

> 1801:                 addVars(c.stats, switchEnv.info.scope);
> 1802: 
> 1803:                 preFlow(c);

this makes sense, we are doing the same for lambdas

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

Marked as reviewed by vromero (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/5836


More information about the compiler-dev mailing list