Sure thing. Here's a Java example:
void sample(Function<String, Integer> fn) {
System.out.println("fn");
}
void sample(Supplier<Integer> sp) {
System.out.println("sp");
}
These methods can exist side by side, and are called correctly even in cases
of Lambda, eg:
sample(s -> 123); // fn
sample(() -> 123); // sp
On the other hand, take this Groovy code:
def sample(Function<String, Integer> fn) {
println "fn"
}
def sample(Supplier<Integer> sp) {
println "sp"
}
With attempted invocation:
sample({ s -> 1 })
This produces an error:
Cannot resolve which method to invoke for [class Script1$_run_closure1] due
to overlapping prototypes between:
[interface java.util.function.Function]
[interface java.util.function.Supplier]
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html