RFR: 8318144: Match on enum constants with body compiles but fails with MatchException [v2]
Jan Lahoda
jlahoda at openjdk.org
Mon Nov 6 07:34:38 UTC 2023
> 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:
Re-ordering tests as suggested.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/16499/files
- new: https://git.openjdk.org/jdk/pull/16499/files/cd27e6e9..5f40a8eb
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=16499&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=16499&range=00-01
Stats: 6 lines in 1 file changed: 4 ins; 1 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/16499.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16499/head:pull/16499
PR: https://git.openjdk.org/jdk/pull/16499
More information about the compiler-dev
mailing list