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

javac rejects valid assignment for incompatible types

XMLWordPrintable

    • generic
    • generic

      MyClass is rejected by javac with the following error:

      incompatible types
      found : java.util.Collection<java.lang.String>
      required: java.util.Collection<java.lang.Object>

      -----------------------------------------------------------------------
      import java.util.Collection;

      public class MyClass {
      public static <E, F extends E> Collection<E> foo(F val) { return null; }

      public static void tryIt() { Collection<Object> obj = foo("bar"); }
      }

            Unassigned Unassigned
            wtaosunw Wei Tao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: