summaryrefslogtreecommitdiff
path: root/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java')
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java21
1 files changed, 11 insertions, 10 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 f16231ac8d26..6098199c591c 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
@@ -379,7 +379,7 @@ public class InferenceSession {
PsiType returnType = method.getReturnType();
if (!PsiType.VOID.equals(returnType) && returnType != null) {
PsiType targetType = getTargetType(context);
- if (targetType != null) {
+ if (targetType != null && !PsiType.VOID.equals(targetType)) {
registerReturnTypeConstraints(PsiUtil.isRawSubstitutor(method, mySiteSubstitutor) ? returnType : mySiteSubstitutor.substitute(returnType), targetType);
}
}
@@ -970,7 +970,8 @@ public class InferenceSession {
addConstraint(new TypeCompatibilityConstraint(getParameterType(parameters, i, PsiSubstitutor.EMPTY, varargs), pType));
}
}
- else if (parameters.length + 1 == functionalMethodParameters.length && !varargs || !isStatic && varargs && functionalMethodParameters.length > 0) { //instance methods
+ else if (parameters.length + 1 == functionalMethodParameters.length && !varargs ||
+ !isStatic && varargs && functionalMethodParameters.length > 0 && PsiMethodReferenceUtil.hasReceiver(reference, method)) { //instance methods
initBounds(containingClass.getTypeParameters());
final PsiType pType = signature.getParameterTypes()[0];
@@ -1020,13 +1021,13 @@ public class InferenceSession {
*/
public static boolean isMoreSpecific(PsiMethod m1,
PsiMethod m2,
- PsiSubstitutor siteSubstitutor2,
PsiExpression[] args,
PsiElement context,
boolean varargs) {
- final PsiTypeParameter[] typeParameters = m2.getTypeParameters();
-
- final InferenceSession session = new InferenceSession(typeParameters, siteSubstitutor2, m2.getManager(), context);
+ final InferenceSession session = new InferenceSession(PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY, m2.getManager(), context);
+ for (PsiTypeParameter param : PsiUtil.typeParametersIterable(m2)) {
+ session.initBounds(param);
+ }
final PsiParameter[] parameters1 = m1.getParameterList().getParameters();
final PsiParameter[] parameters2 = m2.getParameterList().getParameters();
@@ -1036,8 +1037,8 @@ public class InferenceSession {
final int paramsLength = !varargs ? parameters1.length : parameters1.length - 1;
for (int i = 0; i < paramsLength; i++) {
- PsiType sType = getParameterType(parameters1, i, siteSubstitutor2, false);
- PsiType tType = getParameterType(parameters2, i, siteSubstitutor2, varargs);
+ PsiType sType = getParameterType(parameters1, i, PsiSubstitutor.EMPTY, false);
+ PsiType tType = getParameterType(parameters2, i, PsiSubstitutor.EMPTY, varargs);
if (session.isProperType(sType) && session.isProperType(tType)) {
if (!TypeConversionUtil.isAssignable(tType, sType)) {
return false;
@@ -1054,8 +1055,8 @@ public class InferenceSession {
}
if (varargs) {
- PsiType sType = getParameterType(parameters1, paramsLength, siteSubstitutor2, true);
- PsiType tType = getParameterType(parameters2, paramsLength, siteSubstitutor2, true);
+ PsiType sType = getParameterType(parameters1, paramsLength, PsiSubstitutor.EMPTY, true);
+ PsiType tType = getParameterType(parameters2, paramsLength, PsiSubstitutor.EMPTY, true);
session.addConstraint(new StrictSubtypingConstraint(tType, sType));
}