Community
Participate
Working Groups
Build 3.2RC6 Based on: http://forum.java.sun.com/thread.jspa?threadID=741203&tstart=0 The assignment to "it2" should be rejected: import java.util.*; public class X { static final <T, E extends T> Iterator<T> chain(Iterator<E>... it) { return null; } void foo3() { List<Integer> l1 = Arrays.asList(1, 2, 3); Iterator<Number> it2 = X.chain(l1.iterator(), l1.iterator()); } }
Actually, I believe the code is valid. Inference is performing in 2 passes. 1st pass is inferring from argument types, which is going to bind E to Integer. Since T is still unbound, it will consider extra constraints: 1. expectation from return type as invocation is rhs of assignment: Iterator<T> <: Iterator<Number> 2. expectation from type parameter declared bounds T :> Integer These should yield: T == Number, as this is the only one satisfying both constraints
Added GenericTypeTest#test0999&1000
*** Bug 145420 has been marked as a duplicate of this bug. ***