Community
Participate
Working Groups
Build 3.2RC7 The following code should be accepted: public class X { void foo(L l, C<? extends X> c) { X x = bar(l, c); } <T> T bar(L<T> l, C<? extends T> c) { return null; } } class C<E> {} class L<E> {} considering that the unchecked invocation should denote: #bar(L,C<capture-of ? extend X>), which returns something compatible with X. Currently the compiler is considering the invocation to be: #bar(L,C), which thus returns an Object.
Added GenericTypeTest#test1008-1016. After looking more into this case, the original testcase should be rejected as we did, since inference against raw types should yield a raw method, thus T should be bound to Object and not X. On the following invocation, with javac, bar1() invocation seems to return 'X', where bar2() and bar3() are instead doing raw type conversions on return type. Our compiler is consistently doing raw conversion here. public class X { void foo(L l, C<X> c) { X x = bar1(l, c); L<X> lx = bar2(l, c); C<X> cx = bar3(l, c); } <T> T bar1(L<T> l, C<T> c) { return null; } <T> L<T> bar2(L<T> l, C<T> c) { return null; } <T> C<T> bar3(L<T> l, C<T> c) { return null; } } class C<E> {} class L<E> {}