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

Conflicting bindings accepted in some cases

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b32

      Backports

        Description

        Originally reported here:
        https://mail.openjdk.java.net/pipermail/amber-dev/2019-December/005413.html

        Cases like:
        ---
          static void test(Object o1, Object o2) {
              boolean b = o1 instanceof String s && (!(o2 instanceof String s)
        || consume(s));
          }
        ---

        or:
        ---
          static void test(Object o1, Object o2, Object o3) {
            boolean b1 = o1 instanceof String s ? o2 instanceof String s : o3
        instanceof String s;
          }
        ---

        Are not valid and should not compile, but javac currently accepts them without any compile-time error.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jlahoda Jan Lahoda
                Reporter:
                jlahoda Jan Lahoda
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: