RFR: 8314423: Multiple patterns without unnamed variables

Jan Lahoda jlahoda at openjdk.org
Wed Aug 16 15:12:11 UTC 2023


On Wed, 16 Aug 2023 14:52:14 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

> This PR addresses both [JDK-8314423](https://bugs.openjdk.org/browse/JDK-8314423) and [JDK-8314216](https://bugs.openjdk.org/browse/JDK-8314216), since both are relevant to checks around the structure of switch in the relevant method in `Check`. Additionally a check was needed in `analyzePattern` to detect that when a case starts with a constant case label followed by a `,` or `->` is indeed a constant expression and not a pattern as previously signified.

Looks reasonable, with some comments.

test/langtools/tools/javac/T8314216.java line 20:

> 18: 
> 19:     public static void main(String[] args) {
> 20:         new Test().test("ddd");

Note `Test` is not in scope here (not declared), which is the cause of the `cant.resolve.location` error. Is there a reason to keep the `main` method here? Seems to me it should be fine to simply remove it?

test/langtools/tools/javac/T8314423.java line 4:

> 2:  * @test  /nodynamiccopyright/
> 3:  * @bug 8314423
> 4:  * @summary Multiple patterns without unnamed variables

Maybe use `@enablePreview` instead of `--enable-preview`?

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

PR Review: https://git.openjdk.org/jdk/pull/15310#pullrequestreview-1580855285
PR Review Comment: https://git.openjdk.org/jdk/pull/15310#discussion_r1296061208
PR Review Comment: https://git.openjdk.org/jdk/pull/15310#discussion_r1296061693


More information about the compiler-dev mailing list