Generics interface method signature "incorrect"

Viewed 741

I had a hard time thinking of a title for this, so do forgive me.

I have an interface with the following methods:

public interface Algorithm<E,F> {
    public Set<? extends Algorithm<E,F>> map(int numPartitions);
    public F reduce(Set<? extends Algorithm<E,F>> partitions);
}

and a class implementing Algorithm with the following methods:

public class LinearSearch<T> implements Algorithm<List<T>, Integer> {
    @Override
    public Set<LinearSearch<T>> map(int numPartitions) {
        return null;
    }

    @Override
    public Integer reduce(Set<LinearSearch<T>> partitions) {
        return null;
    }
}

Now the odd thing is that Eclipse is complaining about the second method, reduce.

The method reduce(Set<LinearSearch<T>>) of type LinearSearch<T> must override or implement a supertype method.

This is despite the fact that the map method is fine. So where am I going wrong?

2 Answers
Related