don't calculate type of method expression which is located on the left side of assignment - assignment is invalid anyway

(EA-77049 - assert: PsiMethodCallExpressionImpl$TypeEvaluator.fun)
This commit is contained in:
Anna.Kozlova
2016-04-19 14:22:18 +02:00
parent 530b0b04e5
commit abf32b50d5
3 changed files with 26 additions and 1 deletions

View File

@@ -161,9 +161,9 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
final JavaResolveResult[] results = methodExpression.multiResolve(false);
LanguageLevel languageLevel = PsiUtil.getLanguageLevel(call);
final PsiElement callParent = PsiUtil.skipParenthesizedExprUp(call.getParent());
final PsiExpressionList parentArgList;
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
final PsiElement callParent = PsiUtil.skipParenthesizedExprUp(call.getParent());
parentArgList = callParent instanceof PsiConditionalExpression && !PsiPolyExpressionUtil.isPolyExpression((PsiExpression)callParent)
? null : PsiTreeUtil.getParentOfType(call, PsiExpressionList.class);
}
@@ -177,6 +177,9 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
final JavaResolveResult candidateInfo = results[i];
if (genericMethodCall && PsiPolyExpressionUtil.isMethodCallPolyExpression(call, (PsiMethod)candidateInfo.getElement())) {
if (callParent instanceof PsiAssignmentExpression) {
return null;
}
LOG.error("poly expression evaluation during overload resolution");
}

View File

@@ -0,0 +1,18 @@
class Test {
public void myMethod()
{
foo ( <error descr="Variable expected">bar("")</error> = "");
}
private <T> T foo(final T bar) {
return null;
}
private <T> T foo(final String bar) {
return null;
}
private <S> S bar(final String s) {
return null;
}
}

View File

@@ -433,6 +433,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testPolyMethodCallOnLeftSideOfAssignment() throws Exception {
doTest();
}
public void testVariableNamesOfNestedCalls() throws Exception {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
String filePath = BASE_PATH + "/" + getTestName(false) + ".java";