RFR: 8318144: Match on enum constants with body compiles but fails with MatchException
Jan Lahoda
jlahoda at openjdk.org
Fri Nov 3 16:32:16 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
-------------
Commit messages:
- 8318144: Match on enum constants with body compiles but fails with MatchException
Changes: https://git.openjdk.org/jdk/pull/16499/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16499&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8318144
Stats: 109 lines in 3 files changed: 107 ins; 0 del; 2 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