[JSR308] Enhanced for loops

Mahmood Ali mahmood at MIT.EDU
Mon Aug 4 23:06:24 EDT 2008


Hi Artemus,

> As it currently stands the code [...] determine[s] if the generic  
> type parameter of the iterable matches the element. This may be fine  
> in some cases, but it assumes that annotations are copied from the  
> parameter type to the returned value.
>
> 2. Instead of using the type of the Iterable type parameter, use the  
> return type of iterator().next() to emulate what is actually  
> happening in the loop.

Can you please provide a use case for this proposal?

Personally, I think that it's essential that the return type of  
Iterator.next() is the same as the type variable of Iterator.  I think  
that this is important to maintain the subtype relations with  
Iterator<E>.

Thanks,

Mahmood




More information about the JSR308 mailing list