mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: do not use nested call args to infer on the top level
This commit is contained in:
+2
-3
@@ -69,16 +69,15 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
public InferenceSession(PsiTypeParameter[] typeParams,
|
||||
PsiParameter[] parameters,
|
||||
PsiExpression[] args,
|
||||
PsiSubstitutor siteSubstitutor,
|
||||
PsiElement parent,
|
||||
PsiManager manager) {
|
||||
myManager = manager;
|
||||
mySiteSubstitutor = siteSubstitutor;
|
||||
|
||||
initBounds(typeParams);
|
||||
}
|
||||
|
||||
public void initExpressionConstraints(PsiParameter[] parameters, PsiExpression[] args, PsiElement parent) {
|
||||
final Pair<PsiMethod, PsiCallExpression> pair = getPair(parent);
|
||||
if (parameters.length > 0) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
|
||||
+4
-4
@@ -38,8 +38,8 @@ public class PsiGraphInferenceHelper implements PsiInferenceHelper {
|
||||
@NotNull PsiSubstitutor partialSubstitutor,
|
||||
@Nullable PsiElement parent,
|
||||
@NotNull ParameterTypeInferencePolicy policy) {
|
||||
final InferenceSession inferenceSession =
|
||||
new InferenceSession(new PsiTypeParameter[]{typeParameter}, parameters, arguments, partialSubstitutor, parent, myManager);
|
||||
final InferenceSession inferenceSession = new InferenceSession(new PsiTypeParameter[]{typeParameter}, partialSubstitutor, myManager);
|
||||
inferenceSession.initExpressionConstraints(parameters, arguments, parent);
|
||||
return inferenceSession.infer(parameters, arguments, parent).substitute(typeParameter);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public class PsiGraphInferenceHelper implements PsiInferenceHelper {
|
||||
@NotNull ParameterTypeInferencePolicy policy,
|
||||
@NotNull LanguageLevel languageLevel) {
|
||||
if (typeParameters.length == 0) return partialSubstitutor;
|
||||
final InferenceSession inferenceSession =
|
||||
new InferenceSession(typeParameters, parameters, arguments, partialSubstitutor, parent, myManager);
|
||||
final InferenceSession inferenceSession = new InferenceSession(typeParameters, partialSubstitutor, myManager);
|
||||
inferenceSession.initExpressionConstraints(parameters, arguments, parent);
|
||||
return inferenceSession.infer(parameters, arguments, parent);
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -83,11 +83,9 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
InferenceSession callSession = null;
|
||||
if (method != null && !method.isConstructor()) {
|
||||
returnType = method.getReturnType();
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (returnType != null) {
|
||||
callSession = new InferenceSession(method.getTypeParameters(), parameters,
|
||||
argumentList.getExpressions(),
|
||||
PsiSubstitutor.EMPTY, null, myExpression.getManager());
|
||||
callSession = new InferenceSession(method.getTypeParameters(),
|
||||
PsiSubstitutor.EMPTY, myExpression.getManager());
|
||||
|
||||
}
|
||||
} else if (myExpression instanceof PsiNewExpression) { //default constructor
|
||||
@@ -97,9 +95,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
if (psiClass instanceof PsiClass) {
|
||||
returnType = JavaPsiFacade.getElementFactory(argumentList.getProject()).createType((PsiClass)psiClass, PsiSubstitutor.EMPTY);
|
||||
callSession = new InferenceSession(((PsiClass)psiClass).getTypeParameters(),
|
||||
PsiParameter.EMPTY_ARRAY,
|
||||
argumentList.getExpressions(),
|
||||
PsiSubstitutor.EMPTY, null, myExpression.getManager());
|
||||
PsiSubstitutor.EMPTY, myExpression.getManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user