mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: cheat about isPolyExpression to minimize resolution costs
This commit is contained in:
+16
-4
@@ -278,8 +278,7 @@ public class InferenceSession {
|
||||
if (arg instanceof PsiCallExpression) {
|
||||
//If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12),
|
||||
//the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
|
||||
final JavaResolveResult resolveResult = getMethodResult((PsiCallExpression)arg);
|
||||
final PsiMethod calledMethod = resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
|
||||
final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)arg);
|
||||
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
|
||||
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)arg);
|
||||
}
|
||||
@@ -290,6 +289,20 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
|
||||
private static PsiMethod getCalledMethod(PsiCallExpression arg) {
|
||||
final PsiExpressionList argumentList = arg.getArgumentList();
|
||||
if (argumentList == null || argumentList.getExpressions().length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
|
||||
if (properties != null) {
|
||||
return properties.getMethod();
|
||||
}
|
||||
final JavaResolveResult resolveResult = getMethodResult(arg);
|
||||
return resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
|
||||
}
|
||||
|
||||
private void collectLambdaReturnExpression(Set<ConstraintFormula> additionalConstraints,
|
||||
PsiLambdaExpression lambdaExpression,
|
||||
PsiType parameterType) {
|
||||
@@ -306,8 +319,7 @@ public class InferenceSession {
|
||||
PsiExpression returnExpression,
|
||||
PsiType functionalType) {
|
||||
if (returnExpression instanceof PsiCallExpression) {
|
||||
final JavaResolveResult resolveResult = getMethodResult((PsiCallExpression)returnExpression);
|
||||
final PsiMethod calledMethod = resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
|
||||
final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)returnExpression);
|
||||
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(returnExpression, calledMethod)) {
|
||||
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)returnExpression);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user