I have replicated an error that I ran into while using Java 8 @FunctionalInterface
(eclipse). The following does not compile; Refined
produces the error:
@FunctionalInterface
interface Functioner<TFunnel, TFan> {
Function<TFunnel, TFan> funnelledThenFanned();
}
@FunctionalInterface
interface Receiver<T, TFan>
extends Functioner<Supplier<? extends T>, TFan> {}
@FunctionalInterface
interface Giver<TFunnel, T>
extends Functioner<TFunnel, Supplier<T>> {}
@FunctionalInterface
interface Refined<T, R>
extends Function<T, R>, Receiver<T, Supplier<R>>, Giver<Supplier<? extends T>, R> {
@Override
public abstract R apply(T arg);
@Override
public default Function<Supplier<? extends T>, Supplier<R>> funnelledThenFanned() {
...
}
}
Refined
extending all of Function
, Receiver
and Giver
causes the error; remove any one of these, and the code compiles. Is this the correct behavior? If so, how can/should I refactor?
UPDATE
This seems to produce a similar error:
@FunctionalInterface
interface Another<TFunnel, T>
extends Functioner<TFunnel, Supplier<T>>, Giver<TFunnel, T> {
public abstract void newMethod();
@Override
public default Function<TFunnel, Supplier<T>> funnelledThenFanned() {
...
}
}
Also, I'll note that without @FunctionalInterface
everything compiles; interface instances just cannot be expressed as a lambda.
This was Eclipse bug 453552, which was fixed as of 4.6M1, so any Neon release (currently Neon.1, soon Neon.2) contains the fix.