method refs: ambiguity (IDEA-113078)

This commit is contained in:
Anna Kozlova
2013-09-04 13:46:45 +04:00
parent a3afcb0939
commit 0622404265
3 changed files with 30 additions and 1 deletions
@@ -0,0 +1,29 @@
class App {
public static void main(String[] args) {
test(App::getLength);
}
private static Integer getLength(String word) {
return word.length();
}
private static void <warning descr="Private method 'test(App.Consumer<java.lang.String>)' is never used">test</warning>(Consumer<String> consumer) {
consumer.accept("Hello World");
}
private static void test(Function<String, Integer> function) {
Integer result = function.apply("Hello World");
System.out.println(result);
}
interface Function<T, R> {
R apply(T t);
}
interface Consumer<T> {
void accept(T t);
}
}