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

Incorrect error message when type test pattern involves primitive types.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-amber
    • None
    • tools
    • generic
    • generic

      While compiling:

      public class X {
          public static void main(String [] args) {
              Object o = args;
              if (o __matches int s) {
                  System.out.println("Broken");
              } else {
                  System.out.println("!Broken");
              }
          }
      }


      I get:

      /home/srikanth/tmp/X.java:4: error: bad operand types for binary operator '=='
              if (o __matches int s) {
                    ^
        first type: int
        second type: Object
      1 error

      This is surprising.

            gbierman Gavin Bierman
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: