ensure resolve is not cached during overload resolution

This commit is contained in:
Anna Kozlova
2015-02-23 19:39:32 +01:00
parent 8b7325aae5
commit 4819405128
3 changed files with 36 additions and 6 deletions

View File

@@ -312,17 +312,17 @@ public class MethodCandidateInfo extends CandidateInfo{
public static CurrentCandidateProperties getCurrentMethod(PsiElement context) {
if (isOverloadCheck()) {
ourOverloadGuard.prohibitResultCaching(ourOverloadGuard.currentStack().get(0));
}
final Map<PsiElement, CurrentCandidateProperties> currentMethodCandidates = CURRENT_CANDIDATE.get();
return currentMethodCandidates != null ? currentMethodCandidates.get(context) : null;
}
public static void updateSubstitutor(PsiElement context, PsiSubstitutor newSubstitutor) {
final Map<PsiElement, CurrentCandidateProperties> currentMethodCandidates = CURRENT_CANDIDATE.get();
if (currentMethodCandidates != null) {
final CurrentCandidateProperties properties = currentMethodCandidates.get(context);
if (properties != null) {
properties.setSubstitutor(newSubstitutor);
}
CurrentCandidateProperties candidateProperties = getCurrentMethod(context);
if (candidateProperties != null) {
candidateProperties.setSubstitutor(newSubstitutor);
}
}

View File

@@ -0,0 +1,21 @@
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
abstract class Token {
private static B<Long> getMode(Optional<Map.Entry<Integer, Long>> max){
return max
.flatMap(e -> Optional.of(new B<>(Long.valu<ref>eOf(e.getValue().longValue()))))
.get();
}
static class B<K> {
public B(K k) {}
}
}

View File

@@ -21,6 +21,7 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.ResolveTestCase;
@@ -30,6 +31,14 @@ public class TypeInference18Test extends ResolveTestCase {
doTest();
}
public void testSecondConflictResolution() throws Exception {
PsiReference ref = configureByFile("/codeInsight/daemonCodeAnalyzer/lambda/resolve/" + getTestName(false) + ".java");
assertNotNull(ref);
PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(ref.getElement(), PsiMethodCallExpression.class);
assertNotNull(methodCallExpression);
assertNotNull(methodCallExpression.resolveMethod());
}
private LanguageLevel myOldLanguageLevel;
@Override