method refs: ambiguity (IDEA-113078)

This commit is contained in:
Anna Kozlova
2013-09-03 17:51:40 +04:00
parent a3afcb0939
commit 0622404265
3 changed files with 30 additions and 1 deletions

View File

@@ -693,7 +693,6 @@ public class LambdaUtil {
}
private static int isMoreSpecific(PsiType returnType, PsiType returnType1, PsiType lambdaType) {
if (returnType == PsiType.VOID || returnType1 == PsiType.VOID) return 0;
TypeKind typeKind = TypeKind.PRIMITIVE;
if (lambdaType instanceof PsiLambdaExpressionType) {
typeKind = areLambdaReturnExpressionsPrimitive((PsiLambdaExpressionType)lambdaType);

View File

@@ -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);
}
}

View File

@@ -79,6 +79,7 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testMethodRefAcceptance() { doTest(); }
public void testVarargsMethodRef() { doTest(); }
public void testExprReceiver() { doTest(); }
public void testVoidReturnTypeAmbiguity() { doTest(true); }
public void testTypeParameterWithExtendsList() throws Exception {
doTest();