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

Unchecked warning *and* inconvertible types

XMLWordPrintable

    • b48
    • generic
    • generic
    • Verified

      The compiler generates both a warning and an error on this program:

      class Outer<T extends Number & Comparable<String>> {
          void foo(T t) {
              Comparable<Integer> ci = (Comparable<Integer>) t;
          }
      }

      Outer.java:3: warning: [unchecked] unchecked cast
      found : T
      required: java.lang.Comparable<java.lang.Integer>
              Comparable<Integer> ci = (Comparable<Integer>) t;
                                                             ^
      Outer.java:3: inconvertible types
      found : T
      required: java.lang.Comparable<java.lang.Integer>
              Comparable<Integer> ci = (Comparable<Integer>) t;
                                                             ^
      1 error
      1 warning

            mcimadamore Maurizio Cimadamore
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: