RFR: 8318144: Match on enum constants with body compiles but fails with MatchException [v3]

Vicente Romero vromero at openjdk.org
Mon Nov 6 21:04:32 UTC 2023


On Mon, 6 Nov 2023 20:47:06 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
>
> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adding tests as suggested.

lgtm, thanks!

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

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16499#pullrequestreview-1716233470


More information about the compiler-dev mailing list