diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
index f552a66c25ab..30897a12a7dc 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
@@ -1222,6 +1222,23 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
}
}
+
+ if (!myHolder.hasErrorResults()) {
+ PsiElement qualifier = expression.getQualifier();
+ if (qualifier instanceof PsiTypeElement) {
+ final PsiType psiType = ((PsiTypeElement)qualifier).getType();
+ final HighlightInfo genericArrayCreationInfo = GenericsHighlightUtil.checkGenericArrayCreation(qualifier, psiType);
+ if (genericArrayCreationInfo != null) {
+ myHolder.add(genericArrayCreationInfo);
+ } else {
+ final String wildcardMessage = PsiMethodReferenceUtil.checkTypeArguments((PsiTypeElement)qualifier, psiType);
+ if (wildcardMessage != null) {
+ myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(qualifier).descriptionAndTooltip(wildcardMessage).create());
+ }
+ }
+ }
+ }
+
if (!myHolder.hasErrorResults()) {
myHolder.add(HighlightUtil.checkUnhandledExceptions(expression, expression.getTextRange()));
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
index f5f0bf96d95b..d16425632b0e 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
@@ -444,4 +444,19 @@ public class PsiMethodReferenceUtil {
return method.getParameterList().getParametersCount() + 1 == parameterTypes.length &&
hasReceiver(parameterTypes, qualifierResolveResult, methodRef);
}
+
+ public static String checkTypeArguments(PsiTypeElement qualifier, PsiType psiType) {
+ if (psiType instanceof PsiClassType) {
+ final PsiJavaCodeReferenceElement referenceElement = qualifier.getInnermostComponentReferenceElement();
+ if (referenceElement != null) {
+ PsiType[] typeParameters = referenceElement.getTypeParameters();
+ for (PsiType typeParameter : typeParameters) {
+ if (typeParameter instanceof PsiWildcardType) {
+ return "Unexpected wildcard";
+ }
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodRefAcceptance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodRefAcceptance.java
index dfe9ed6a0d96..315a8e0c8dff 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodRefAcceptance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodRefAcceptance.java
@@ -25,7 +25,7 @@ class Test {
IFactory c1 = Anno::new;
IFactory c2 = E::new;
IFactory c3 = I::new;
- IFactory c4 = Foo>::new;
+ IFactory c4 = Foo>::new;
IFactory c5 = 1::new;
IFactory c6 = ABar::new;
IFactory c7 = ABaz::new;
@@ -33,7 +33,7 @@ class Test {
foo(Anno::new);
foo(E::new);
foo(I::new);
- foo(Foo>::new);
+ foo(Foo>::new);
foo(1::new);
foo(ABar::new);
foo(ABaz::new);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RefOnArrayDeclaration.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RefOnArrayDeclaration.java
index 0fa9c841bad5..ed1efe80d21d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RefOnArrayDeclaration.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RefOnArrayDeclaration.java
@@ -42,7 +42,7 @@ class OnArrayTest {
ArrayReturnType a3 = int[]::new;
ObjectArrayReturnType a4 = Foo>[]::new;
- ObjectArrayReturnType a5 = Foo extends String>[]::new;
+ ObjectArrayReturnType a5 = Foo extends String>[]::new;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/WildcardsInClassTypeQualifier.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/WildcardsInClassTypeQualifier.java
new file mode 100644
index 000000000000..c4bf562d07fc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/WildcardsInClassTypeQualifier.java
@@ -0,0 +1,17 @@
+class Test {
+ interface I {
+ Object foo();
+ }
+
+ static class Foo { }
+
+ {
+ I i1 = Foo>::new;
+ I i2 = Foo extends String>::new;
+ I i3 = Foo::new;
+
+ I i4 = Foo extends String>[]::new;
+ I i5 = Foo[]::new;
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
index 3e671b2fbcee..87d8813e8f86 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
@@ -88,6 +88,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest(true);
}
+ public void testWildcardsInClassTypeQualifier() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}