ignore type parameters (arguments) in non-generic method references

This commit is contained in:
Anna Kozlova
2015-01-31 16:13:12 +03:00
parent d2840c6abe
commit e41b02e277
3 changed files with 30 additions and 1 deletions
@@ -100,7 +100,8 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
final PsiExpressionList argumentList = getArgumentList();
final PsiType[] typeParameters = reference.getTypeParameters();
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
argumentList != null ? argumentList.getExpressionTypes() : null, typeParameters.length > 0 ? typeParameters : null,
argumentList != null ? argumentList.getExpressionTypes() : null,
method.hasTypeParameters() && typeParameters.length > 0 ? typeParameters : null,
getLanguageLevel()) {
@Override
public boolean isVarargs() {
@@ -0,0 +1,24 @@
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
abstract class Test {
void p(final Stream<List<Integer>> stream){
stream.flatMap(Collection::<String>stream);
stream.flatMap(Collection::<<error descr="Unexpected wildcard">? extends String</error>>stream);
stream.flatMap(Collection::<<error descr="Unexpected wildcard">?</error>>stream);
stream.flatMap(Collection::<<error descr="Unexpected wildcard">? super String</error>>stream);
}
static <T> void foo(T t) {}
interface I {
void m(String s);
}
{
I i = Test::<String>foo;
I i1 = Test::<Integer><error descr="Cannot resolve method 'foo'">foo</error>;
I i2 = Test::foo;
}
}
@@ -346,6 +346,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testMethodReferenceTypeArgumentsApplicability() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}