Translation for instanceof is not triggered when patterns are not used in the compilation unit

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 24
    • Affects Version/s: None
    • Component/s: tools
    • None
    • b27

      When instanceof as a type comparison operator is used without any patterns in the current compilation unit, desugaring is skipped.

      Sample 1:

      import java.util.List;

      public class Test {
            
          public static void main(String argv[]) {
                  List<Short> ls = List.of((short) 42);
                  System.out.println(ls.get(0) instanceof int);
                  //System.out.println(ls.get(0) instanceof int p);       
          }
      }

      output:
      false

      Sample 2:

      import java.util.List;

      public class Test {
            
          public static void main(String argv[]) {
                  List<Short> ls = List.of((short) 42);
                  System.out.println(ls.get(0) instanceof int);
                  System.out.println(ls.get(0) instanceof int p);       
          }
      }

      Output:
      true
      true

            Assignee:
            Angelos Bimpoudis
            Reporter:
            Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: