diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java index 9766122e31d0..9c8b8b4772b3 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java @@ -89,28 +89,6 @@ public class InferenceIncorporationPhase { upDown(lowerBounds, eqBounds, substitutor); upUp(upperBounds); - - for (PsiType eqBound : eqBounds) { - if (mySession.isProperType(eqBound)) { - for (PsiType upperBound : upperBounds) { - if (!mySession.isProperType(upperBound)) { - addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), eqBound)); - } - } - - for (PsiType lowerBound : lowerBounds) { - if (!mySession.isProperType(lowerBound)) { - addConstraint(new StrictSubtypingConstraint(eqBound, substitutor.substitute(lowerBound))); - } - } - - for (PsiType otherEqBound : eqBounds) { - if (eqBound != otherEqBound && !mySession.isProperType(otherEqBound)) { - addConstraint(new TypeEqualityConstraint(substitutor.substitute(otherEqBound), eqBound)); - } - } - } - } } for (Pair capture : myCaptures) { @@ -135,7 +113,7 @@ public class InferenceIncorporationPhase { if (aType instanceof PsiWildcardType) { for (PsiType eqBound : eqBounds) { - if (mySession.isProperType(eqBound)) return false; + if (mySession.getInferenceVariable(eqBound) == null) return false; } final PsiClassType[] paramBounds = parameters[i].getExtendsListTypes(); @@ -143,15 +121,15 @@ public class InferenceIncorporationPhase { if (!((PsiWildcardType)aType).isBounded()) { for (PsiType upperBound : upperBounds) { - if (mySession.isProperType(upperBound)) { + if (mySession.getInferenceVariable(upperBound) == null) { for (PsiClassType paramBound : paramBounds) { - addConstraint(new StrictSubtypingConstraint(upperBound, paramBound)); + addConstraint(new StrictSubtypingConstraint(upperBound, mySession.substituteWithInferenceVariables(paramBound))); } } } for (PsiType lowerBound : lowerBounds) { - if (mySession.isProperType(lowerBound)) return false; + if (mySession.getInferenceVariable(lowerBound) == null) return false; } } else if (((PsiWildcardType)aType).isExtends()) { @@ -159,19 +137,19 @@ public class InferenceIncorporationPhase { final PsiType extendsBound = ((PsiWildcardType)aType).getExtendsBound(); for (PsiType upperBound : upperBounds) { - if (mySession.isProperType(upperBound)) { + if (mySession.getInferenceVariable(upperBound) == null) { if (paramBounds.length == 1 && paramBounds[0].equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || paramBounds.length == 0) { addConstraint(new StrictSubtypingConstraint(upperBound, extendsBound)); } else if (extendsBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) { for (PsiClassType paramBound : paramBounds) { - addConstraint(new StrictSubtypingConstraint(upperBound, paramBound)); + addConstraint(new StrictSubtypingConstraint(upperBound, mySession.substituteWithInferenceVariables(paramBound))); } } } } for (PsiType lowerBound : lowerBounds) { - if (mySession.isProperType(lowerBound)) return false; + if (mySession.getInferenceVariable(lowerBound) == null) return false; } } else { @@ -179,15 +157,15 @@ public class InferenceIncorporationPhase { final PsiType superBound = ((PsiWildcardType)aType).getSuperBound(); for (PsiType upperBound : upperBounds) { - if (mySession.isProperType(upperBound)) { + if (mySession.getInferenceVariable(upperBound) == null) { for (PsiClassType paramBound : paramBounds) { - addConstraint(new StrictSubtypingConstraint(paramBound, upperBound)); + addConstraint(new StrictSubtypingConstraint(mySession.substituteWithInferenceVariables(paramBound), upperBound)); } } } for (PsiType lowerBound : lowerBounds) { - if (mySession.isProperType(lowerBound)) { + if (mySession.getInferenceVariable(lowerBound) == null) { addConstraint(new StrictSubtypingConstraint(lowerBound, superBound)); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index d423cbbe83af..35db6c29bc0c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -875,7 +875,7 @@ public class InferenceSession { } //resolve input variables - PsiSubstitutor substitutor = resolveSubset(varsToResolve, retrieveNonPrimitiveEqualsBounds(getInferenceVariables()).putAll(siteSubstitutor)); + PsiSubstitutor substitutor = resolveSubset(varsToResolve, siteSubstitutor); if (substitutor == null) { return false; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/WildcardParametrization.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/WildcardParametrization.java new file mode 100644 index 000000000000..d1adfe4a9ee1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/WildcardParametrization.java @@ -0,0 +1,19 @@ + +import java.util.function.Function; + +class IdeaTest { + class Test{} + + public void checkAnnotationsPresent() { + Function, Annotation> mapper = this::getAnnotation; + Function, ? extends Annotation> mapper1 = this::getAnnotation; + } + + public A getAnnotation(Test annotationClass) { + return null; + } + + static class Annotation{} + + +} 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 42a7fd8d671f..8a0631e67a78 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 @@ -310,6 +310,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testWildcardParametrization() throws Exception { + doTest(); + } + private void doTest() { doTest(false); }