mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
java inference: ensure that applicability check is not re-entered
this fixes assertion at com.intellij.util.ObjectUtils.assertNotNull(ObjectUtils.java:84) at com.intellij.psi.infos.MethodCandidateInfo.inferTypeArguments(MethodCandidateInfo.java:453) caused by including expression compatibility constraints for expressions inside lambdas for which parameter types are calculated GitOrigin-RevId: 0588bff4a719fb73ff49a51bc86635e56cd8d146
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6e6d49014c
commit
d829a7c8f4
@@ -156,7 +156,9 @@ public class InferenceSession {
|
||||
|
||||
if (args[i] != null && isPertinentToApplicability(args[i], method)) {
|
||||
PsiType parameterType = getParameterType(parameters, i, mySiteSubstitutor, varargs);
|
||||
addConstraint(new ExpressionCompatibilityConstraint(args[i], substituteWithInferenceVariables(parameterType)));
|
||||
if (!ignoreLambdaConstraintTree(args[i])) {
|
||||
addConstraint(new ExpressionCompatibilityConstraint(args[i], substituteWithInferenceVariables(parameterType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,9 @@ public class LambdaExpressionCompatibilityConstraint implements ConstraintFormul
|
||||
});
|
||||
if (!isProperType || myExpression.hasFormalParameterTypes()) {
|
||||
for (PsiExpression returnExpression : returnExpressions) {
|
||||
constraints.add(new ExpressionCompatibilityConstraint(returnExpression, returnType));
|
||||
if (!InferenceSession.ignoreLambdaConstraintTree(returnExpression)) {
|
||||
constraints.add(new ExpressionCompatibilityConstraint(returnExpression, returnType));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
class AsyncContext {
|
||||
|
||||
public static <T> T computeOnEdt(Supplier<T> supplier) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <K, V> ConcurrentMap<K, V> create(Function<? super K, ? extends V> computeValue,
|
||||
Supplier<? extends ConcurrentMap<K, V>> mapCreator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Provider provider = null;
|
||||
|
||||
private final Map<Component, Provider> myProviders = create(key->
|
||||
computeOnEdt(() -> {
|
||||
return dataKey -> {
|
||||
return computeOnEdt(() -> {
|
||||
return provider.get<caret>Data(dataKey);
|
||||
});
|
||||
};
|
||||
}),
|
||||
|
||||
AsyncContext::createConcurrentWeakKeySoftValueMap
|
||||
);
|
||||
|
||||
public static <K,V> ConcurrentMap<K,V> createConcurrentWeakKeySoftValueMap() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Component {}
|
||||
|
||||
interface Provider {
|
||||
Object getData(String key);
|
||||
}
|
||||
@@ -57,6 +57,16 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
|
||||
assertEquals(CommonClassNames.JAVA_LANG_STRING, type.getCanonicalText());
|
||||
}
|
||||
|
||||
public void testRecursiveApplicabilityCheck() {
|
||||
configure();
|
||||
PsiMethodCallExpression getDataCall =
|
||||
PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiMethodCallExpression.class);
|
||||
assertNotNull(getDataCall);
|
||||
|
||||
//ensure applicability is not called recursively
|
||||
assertNotNull(getDataCall.getType());
|
||||
}
|
||||
|
||||
public void testLambdaParameterTypeDetection() {
|
||||
configure();
|
||||
PsiReferenceExpression referenceExpression =
|
||||
|
||||
Reference in New Issue
Block a user