mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
infer conditional expression type for incomplete calls (IDEA-171431)
This commit is contained in:
+5
-4
@@ -890,7 +890,7 @@ public class InferenceSession {
|
||||
if (argumentList != null) {
|
||||
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
|
||||
if (properties != null && properties.isApplicabilityCheck()) {
|
||||
return getTypeByMethod(context, argumentList, properties.getMethod(), properties.isVarargs(), properties.getSubstitutor());
|
||||
return getTypeByMethod(context, argumentList, properties.getMethod(), properties.isVarargs(), properties.getSubstitutor(), inferParent);
|
||||
}
|
||||
|
||||
final JavaResolveResult result = ((PsiCall)gParent).resolveMethodGenerics();
|
||||
@@ -901,7 +901,7 @@ public class InferenceSession {
|
||||
}
|
||||
if (element instanceof PsiMethod && (inferParent || !((PsiMethod)element).hasTypeParameters())) {
|
||||
final boolean varargs = result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isVarargs();
|
||||
return getTypeByMethod(context, argumentList, result.getElement(), varargs, result.getSubstitutor());
|
||||
return getTypeByMethod(context, argumentList, result.getElement(), varargs, result.getSubstitutor(), inferParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -946,12 +946,13 @@ public class InferenceSession {
|
||||
PsiExpressionList argumentList,
|
||||
PsiElement parentMethod,
|
||||
boolean varargs,
|
||||
PsiSubstitutor substitutor) {
|
||||
PsiSubstitutor substitutor,
|
||||
boolean inferParent) {
|
||||
if (parentMethod instanceof PsiMethod) {
|
||||
final PsiParameter[] parameters = ((PsiMethod)parentMethod).getParameterList().getParameters();
|
||||
if (parameters.length == 0) return null;
|
||||
final PsiExpression[] args = argumentList.getExpressions();
|
||||
if (!((PsiMethod)parentMethod).isVarArgs() && parameters.length != args.length) return null;
|
||||
if (!((PsiMethod)parentMethod).isVarArgs() && parameters.length != args.length && !inferParent) return null;
|
||||
PsiElement arg = context;
|
||||
while (arg.getParent() instanceof PsiParenthesizedExpression) {
|
||||
arg = arg.getParent();
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
class Test{
|
||||
void test() {
|
||||
B b = new B<error descr="'B(java.lang.String, java.lang.String)' in 'Test.B' cannot be applied to '(?)'">(true == false ? "bar" : null)</error>;
|
||||
B b = new B<error descr="'B(java.lang.String, java.lang.String)' in 'Test.B' cannot be applied to '(java.lang.String)'">(true == false ? "bar" : null)</error>;
|
||||
}
|
||||
|
||||
class B {
|
||||
|
||||
Reference in New Issue
Block a user