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

[lworld] Bogus error: incompatible types: Object cannot be converted to Foo

XMLWordPrintable

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

      Thanks to Maurizio for reporting this:

      // -- X.java
      sealed interface Foo permits Bar { }
      primitive class Bar implements Foo { }

      class Test {
         void test(Object o) {
            Foo foo = (Foo)o;
         }
      }
      $javac -g X.java
      X.java:6: error: incompatible types: Object cannot be converted to Foo
            Foo foo = (Foo)o;
                           ^
      1 error


      Error goes away if interface is not sealed.

            abimpoudis Angelos Bimpoudis
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: