pull up inference errors when current call has no type parameters (IDEA-169316)

This commit is contained in:
Anna.Kozlova
2017-03-09 15:04:34 +01:00
parent 585bf0e512
commit c719482b06
3 changed files with 21 additions and 3 deletions
@@ -111,7 +111,7 @@ public class MethodCandidateInfo extends CandidateInfo{
public int getPertinentApplicabilityLevel() {
if (myPertinentApplicabilityLevel == 0) {
myPertinentApplicabilityLevel = getPertinentApplicabilityLevelInner();
pullInferenceErrorMessagesFromSubexpressions();
myPertinentApplicabilityLevel = pullInferenceErrorMessagesFromSubexpressions();
}
return myPertinentApplicabilityLevel;
}
@@ -474,8 +474,9 @@ public class MethodCandidateInfo extends CandidateInfo{
return errorMessage;
}
private void pullInferenceErrorMessagesFromSubexpressions() {
if (myPertinentApplicabilityLevel == ApplicabilityLevel.NOT_APPLICABLE && myArgumentList instanceof PsiExpressionList) {
private int pullInferenceErrorMessagesFromSubexpressions() {
if (myArgumentList instanceof PsiExpressionList &&
(myPertinentApplicabilityLevel == ApplicabilityLevel.NOT_APPLICABLE || !isToInferApplicability())) {
String errorMessage = null;
for (PsiExpression expression : ((PsiExpressionList)myArgumentList).getExpressions()) {
final String message = clearErrorMessageInSubexpressions(expression);
@@ -485,8 +486,10 @@ public class MethodCandidateInfo extends CandidateInfo{
}
if (errorMessage != null) {
setInferenceError(errorMessage);
return ApplicabilityLevel.NOT_APPLICABLE;
}
}
return myPertinentApplicabilityLevel;
}
private static String clearErrorMessageInSubexpressions(PsiExpression expression) {
@@ -0,0 +1,11 @@
class A<T> {}
class B<K> extends A<String> {}
class X<L> {
public X(A<L> b1) {
this(new B<>());
}
public X(B<L> b2) {}
}
@@ -81,6 +81,10 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testDiamondInsideOverloadedThisReference() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}