new inference: avoid prohibit cashing, don't check exceptions during overload resolution instead (IDEA-139531)

This commit is contained in:
Anna Kozlova
2015-04-27 17:17:02 +02:00
parent 538f104f29
commit 1233bccf4e
4 changed files with 21 additions and 4 deletions

View File

@@ -16,7 +16,6 @@
package com.intellij.psi;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.pom.java.LanguageLevel;
@@ -340,9 +339,6 @@ public class LambdaUtil {
if (gParent instanceof PsiCall) {
final PsiCall contextCall = (PsiCall)gParent;
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(contextCall.getArgumentList());
if (MethodCandidateInfo.isOverloadCheck()) {
MethodCandidateInfo.ourOverloadGuard.prohibitResultCaching(MethodCandidateInfo.ourOverloadGuard.currentStack().get(0));
}
if (properties != null && properties.isApplicabilityCheck()) { //todo simplification
final PsiParameter[] parameters = properties.getMethod().getParameterList().getParameters();
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, properties.getMethod(), parameters);

View File

@@ -409,6 +409,10 @@ public class ExceptionUtil {
public static List<PsiClassType> getUnhandledExceptions(@NotNull final PsiCallExpression methodCall,
@Nullable final PsiElement topElement,
final boolean includeSelfCalls) {
//exceptions only influence the invocation type after overload resolution is complete
if (MethodCandidateInfo.isOverloadCheck()) {
return Collections.emptyList();
}
final JavaResolveResult result = methodCall.resolveMethodGenerics();
final PsiMethod method = (PsiMethod)result.getElement();
if (method == null) {

View File

@@ -0,0 +1,13 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.LongAdder;
class Test {
{
Set<Map.Entry<String, Integer>> sort3 = new TreeSet<>((x, y) -> {
return Integer.compare(x.get<ref>Value(), y.getValue());
});
}
}

View File

@@ -35,6 +35,10 @@ public class TypeInference18Test extends ResolveTestCase {
doTestMethodCall();
}
public void testSecondConflictResolution1() throws Exception {
doTestMethodCall();
}
public void testCachedSubstitutionDuringOverloadResolution() throws Exception {
PsiReference ref = configureByFile("/codeInsight/daemonCodeAnalyzer/lambda/resolve/" + getTestName(false) + ".java");
assertNotNull(ref);