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

Incorrect error message when type test pattern involves primitive types.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: repo-amber
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            gbierman Gavin Bierman
            Reporter:
            sadayapalam Srikanth Adayapalam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: