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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • repo-valhalla
    • Affects Version/s: repo-valhalla
    • Component/s: 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.

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

              Created:
              Updated:
              Resolved: