Integrated: 8318144: Match on enum constants with body compiles but fails with MatchException

Jan Lahoda jlahoda at openjdk.org
Tue Nov 7 12:09:46 UTC 2023


On Fri, 3 Nov 2023 16:26:49 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> For code like:
> 
> enum E {A {}, B {} }
> Object o = E.A;
> switch (o) {
>      case E.A -> System.err.println(o);
>      default -> System.err.println("default");
> }
> 
> 
> The result is `default`, not `A`, due to incorrect classes being compared. Thanks for @liach for noting the solution here:
> https://github.com/openjdk/jdk/pull/16489#discussion_r1381411165

This pull request has now been integrated.

Changeset: 541ff714
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/541ff7149f9c6480535219ab06a2576f8399703a
Stats:     122 lines in 3 files changed: 120 ins; 0 del; 2 mod

8318144: Match on enum constants with body compiles but fails with MatchException

Reviewed-by: liach, vromero

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

PR: https://git.openjdk.org/jdk/pull/16499


More information about the compiler-dev mailing list