mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PsiMethodReferenceUtil#getMethodReferenceReturnType: revert 07a45d1, public delegate instead
Review ID: IDEA-CR-24131
This commit is contained in:
+1
-1
@@ -1432,7 +1432,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
final String badReturnTypeMessage = PsiMethodReferenceUtil.checkReturnType(expression, functionalInterfaceType);
|
||||
final String badReturnTypeMessage = PsiMethodReferenceUtil.checkReturnType(expression, result, functionalInterfaceType);
|
||||
if (badReturnTypeMessage != null) {
|
||||
HighlightInfo info =
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(badReturnTypeMessage).create();
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PsiMethodReferenceUtil {
|
||||
private static final Logger LOG = Logger.getInstance(PsiMethodReferenceUtil.class);
|
||||
|
||||
public static boolean isSecondSearchPossible(PsiType[] parameterTypes,
|
||||
QualifierResolveResult qualifierResolveResult,
|
||||
@@ -69,8 +71,10 @@ public class PsiMethodReferenceUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isReturnTypeCompatible(PsiMethodReferenceExpression expression, PsiType functionalInterfaceType) {
|
||||
return isReturnTypeCompatible(expression, functionalInterfaceType, null);
|
||||
public static boolean isReturnTypeCompatible(PsiMethodReferenceExpression expression,
|
||||
JavaResolveResult result,
|
||||
PsiType functionalInterfaceType) {
|
||||
return isReturnTypeCompatible(expression, result, functionalInterfaceType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +84,17 @@ public class PsiMethodReferenceUtil {
|
||||
* @return an actual method reference return type
|
||||
*/
|
||||
public static PsiType getMethodReferenceReturnType(PsiMethodReferenceExpression expression) {
|
||||
JavaResolveResult result = expression.advancedResolve(false);
|
||||
return getMethodReferenceReturnType(expression, expression.advancedResolve(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns actual return type of method reference (not the expected one)
|
||||
*
|
||||
* @param expression a method reference to get the return type of
|
||||
* @param result the result of method reference resolution
|
||||
* @return an actual method reference return type
|
||||
*/
|
||||
private static PsiType getMethodReferenceReturnType(PsiMethodReferenceExpression expression, JavaResolveResult result) {
|
||||
PsiSubstitutor subst = result.getSubstitutor();
|
||||
|
||||
PsiType methodReturnType = null;
|
||||
@@ -123,6 +137,7 @@ public class PsiMethodReferenceUtil {
|
||||
}
|
||||
|
||||
private static boolean isReturnTypeCompatible(PsiMethodReferenceExpression expression,
|
||||
JavaResolveResult result,
|
||||
PsiType functionalInterfaceType,
|
||||
Ref<String> errorMessage) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
@@ -134,7 +149,7 @@ public class PsiMethodReferenceUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
PsiType methodReturnType = getMethodReferenceReturnType(expression);
|
||||
PsiType methodReturnType = getMethodReferenceReturnType(expression, result);
|
||||
if (methodReturnType == null || PsiType.VOID.equals(methodReturnType)) {
|
||||
return false;
|
||||
}
|
||||
@@ -357,9 +372,9 @@ public class PsiMethodReferenceUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String checkReturnType(PsiMethodReferenceExpression expression, PsiType functionalInterfaceType) {
|
||||
public static String checkReturnType(PsiMethodReferenceExpression expression, JavaResolveResult result, PsiType functionalInterfaceType) {
|
||||
final Ref<String> errorMessage = Ref.create();
|
||||
if (!isReturnTypeCompatible(expression, functionalInterfaceType, errorMessage)) {
|
||||
if (!isReturnTypeCompatible(expression, result, functionalInterfaceType, errorMessage)) {
|
||||
return errorMessage.get();
|
||||
}
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -430,7 +430,7 @@ public class PsiMethodReferenceExpressionImpl extends JavaStubPsiElement<Functio
|
||||
return false;
|
||||
}
|
||||
|
||||
return PsiMethodReferenceUtil.isReturnTypeCompatible(this, left);
|
||||
return PsiMethodReferenceUtil.isReturnTypeCompatible(this, result, left);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user