lambda inference bug

Rémi Forax forax at univ-mlv.fr
Mon Sep 5 06:11:31 PDT 2011


On 09/05/2011 01:11 PM, Maurizio Cimadamore wrote:
> 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

Hi Maurizio,
thank you for the fast fix.

Could you explain me the difference between the inference used by 
default by javac
and the complex inference ?

Rémi

>
> 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