method ref: type parameter instantiation (IDEA-154645)

This commit is contained in:
Anna.Kozlova
2016-04-13 12:30:54 +02:00
parent 5beacf0b13
commit 9086115347
3 changed files with 15 additions and 1 deletions
@@ -54,7 +54,9 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
final PsiElement element = reference.getReferenceNameElement();
final boolean isConstructor = reference.isConstructor();
if (element instanceof PsiIdentifier || isConstructor) {
if (isConstructor && (containingClass.isEnum() || containingClass.hasModifierProperty(PsiModifier.ABSTRACT))) {
if (isConstructor && (containingClass.isEnum() ||
containingClass.hasModifierProperty(PsiModifier.ABSTRACT) ||
containingClass instanceof PsiTypeParameter)) {
return JavaResolveResult.EMPTY_ARRAY;
}
final PsiType functionalInterfaceType = getInterfaceType(reference);
@@ -0,0 +1,8 @@
import java.util.function.Supplier;
class Test<T> {
{
Supplier<T> aNew = T::<error descr="Cannot resolve constructor 'T'">new</error>;
}
}
@@ -506,6 +506,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testTypeParameterInstantiation() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}