Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8289196

Pattern domination not working properly for record patterns

XMLWordPrintable

    • b31
    • Verified

        Consider this code:
        ---
        class RecordPatternDomination {
            void test(Object o) {
                switch (o) {
                    case R(int i) -> {}
                    case R(int i) -> {} //error here - the pattern is dominated
                    default -> {}
                }
            }
            record R(int i) {}
        }
        ---

        This should produce an error, because the second `R(int i)` pattern dominates the first one (JLS 14.30.3), but it does no produce it.

              jlahoda Jan Lahoda
              jlahoda Jan Lahoda
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: