-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
6
-
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"); }
}
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"); }
}
- relates to
-
JDK-6278587 Compiler fails to infer correct type for under-constrained type variables
- Closed