[jdk19] RFR: 8289196: Patttern domination not working property for record patterns

Vicente Romero vromero at openjdk.org
Fri Jul 1 16:46:43 UTC 2022


On Tue, 28 Jun 2022 13:11:25 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> When checking that a pattern in a switch case is not dominated by a preceding pattern, handling for record pattern is mostly missing. This patch is attempting to fix that, and as it requires a bit more code, it moves the check into `Check`.

shouldn't this test case be rejected too:


class TestRecordPattern {
    int testRecordPatternsDominated2() {
        record R(int a) {}
        Object o = null;
        switch (o) {
            //case R(int a): return 1;
            case R(int a) when guard(): return -1;
            case R(int a): return 1;
            default: return 0;
        }
    }

    boolean guard() {
        return false;
    }
}


http://cr.openjdk.java.net/~gbierman/jep427+405/jep427+405-20220601/specs/patterns-switch-record-patterns-jls.html#jls-14.30.3 doesn't mention anything about guards if I understand correctly

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

PR: https://git.openjdk.org/jdk19/pull/84


More information about the compiler-dev mailing list