From 3b9ea8d4a850ecc83abea0552d850dd9c41bef0e Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 28 Jul 2015 21:45:49 +0200 Subject: [PATCH] new inference: check low and eq bounds the same for parameterization --- .../resolve/graphInference/InferenceSession.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 129d00476522..ba65160526e3 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 @@ -613,6 +613,12 @@ public class InferenceSession { return false; } + /** + * T is a reference type, but is not a wildcard-parameterized type, and either + * i) B2 contains a bound of one of the forms α=S or S<:α, where S is a wildcard-parameterized type, or + * ii) B2 contains two bounds of the forms S1 <: α and S2 <: α, + * where S1 and S2 have supertypes that are two different parameterizations of the same generic class or interface. + */ private static boolean hasWildcardParameterization(InferenceVariable inferenceVariable, PsiClassType targetType) { if (!FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) { final List bounds = inferenceVariable.getBounds(InferenceBound.LOWER); @@ -624,13 +630,11 @@ public class InferenceSession { }; if (findParameterizationOfTheSameGenericClass(bounds, differentParameterizationProcessor) != null) return true; final List eqBounds = inferenceVariable.getBounds(InferenceBound.EQ); - for (PsiType lowBound : bounds) { + final List boundsToCheck = new ArrayList(bounds); + boundsToCheck.addAll(eqBounds); + for (PsiType lowBound : boundsToCheck) { if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(lowBound)) { - for (PsiType bound : eqBounds) { - if (lowBound.equals(bound)) { - return true; - } - } + return true; } } }