lambda inference bug

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Sep 5 04:11:13 PDT 2011


Hi,
forget my earlier comment (I misread your example) - this should indeed 
compile, as E gets a lower bound from the first actual argument. This 
has been now fixed in the lambda-repo.

Maurizio

On 05/09/11 09:20, maurizio cimadamore wrote:
>> public class ReducerBug {
>> >     interface Reducer<E, V>  {
>> >       public V reduce(E element, V value);
>> >     }
>> >
>> >     private static<E>  int reduce(Iterable<? extends E>  iterable, int
>> >  initialValue, Reducer<? super E, Integer>  reducer) {
>> >       int value = initialValue;
>> >       for(E e: iterable) {
>> >         value = reducer.reduce(e, value);
>> >       }
>> >       return value;
>> >     }
>> >
>> >     public static void main(String[] args) {
>> >       java.util.List<Integer>  l = java.util.Arrays.asList(1, 2, 3);
>> >       int result = reduce(l, 0, #{ e, v ->  e + v});
>> >       System.out.println(result);
>> >     }
>> >  }



More information about the lambda-dev mailing list