mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
don't cache substitutors during processing of all candidates (blinking red code)
This commit is contained in:
@@ -979,17 +979,25 @@ public class ExpectedTypesProvider {
|
||||
PsiSubstitutor substitutor;
|
||||
if (candidateInfo instanceof MethodCandidateInfo) {
|
||||
final MethodCandidateInfo info = (MethodCandidateInfo)candidateInfo;
|
||||
substitutor = info.inferTypeArguments(policy, args, true);
|
||||
substitutor = MethodCandidateInfo.ourOverloadGuard
|
||||
.doPreventingRecursion(argumentList, false, () -> info.inferTypeArguments(policy, args, true));
|
||||
if (!info.isStaticsScopeCorrect() && method != null && !method.hasModifierProperty(PsiModifier.STATIC)) continue;
|
||||
}
|
||||
else {
|
||||
substitutor = candidateInfo.getSubstitutor();
|
||||
substitutor = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(argumentList, false, candidateInfo::getSubstitutor);
|
||||
}
|
||||
if (substitutor == null) {
|
||||
return ExpectedTypeInfo.EMPTY_ARRAY;
|
||||
}
|
||||
inferMethodCallArgumentTypes(argument, forCompletion, args, index, method, substitutor, array);
|
||||
|
||||
if (leftArgs != null && candidateInfo instanceof MethodCandidateInfo) {
|
||||
substitutor = ((MethodCandidateInfo)candidateInfo).inferTypeArguments(policy, leftArgs, true);
|
||||
inferMethodCallArgumentTypes(argument, forCompletion, leftArgs, index, method, substitutor, array);
|
||||
substitutor = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(argumentList, false,
|
||||
() -> ((MethodCandidateInfo)candidateInfo)
|
||||
.inferTypeArguments(policy, leftArgs, true));
|
||||
if (substitutor != null) {
|
||||
inferMethodCallArgumentTypes(argument, forCompletion, leftArgs, index, method, substitutor, array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.function.Function;
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void m(Set<String> i) {
|
||||
final List<String> getters = new ArrayList<String>(map(i, new Func<caret>tion<String, String>() {
|
||||
@Override
|
||||
public String apply(String propertyName) {
|
||||
return propertyName;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
public static <T,V> List<V> map(Iterable<? extends T> iterable, Function<T, V> mapping) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T,V> List<V> map(Collection<? extends T> iterable, Function<T, V> mapping) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.ExpectedTypesProvider;
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.psi.*;
|
||||
@@ -75,6 +77,17 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
|
||||
doTestAllMethodCallExpressions();
|
||||
}
|
||||
|
||||
public void testNonCachingFolding() throws Exception {
|
||||
final String filePath = BASE_PATH + "/" + getTestName(false) + ".java";
|
||||
configureByFile(filePath);
|
||||
PsiNewExpression newWithAnonym =
|
||||
PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiNewExpression.class);
|
||||
ExpectedTypeInfo[] types = ExpectedTypesProvider.getExpectedTypes(newWithAnonym, false);
|
||||
assertNotNull(types);
|
||||
|
||||
doTestConfiguredFile(false, false, filePath);
|
||||
}
|
||||
|
||||
private void doTestCachedUnresolved() {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
PsiMethodCallExpression callExpression =
|
||||
|
||||
Reference in New Issue
Block a user