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

Conflicting bindings accepted in some cases

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 14
    • 14
    • tools
    • None
    • b32

        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.

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

                Created:
                Updated:
                Resolved: