mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: skip parenthesized expressions during additional constrains collection
This commit is contained in:
+10
-9
@@ -266,21 +266,22 @@ public class InferenceSession {
|
||||
Set<ConstraintFormula> additionalConstraints,
|
||||
boolean varargs, boolean toplevel) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] != null) {
|
||||
final InferenceSession nestedCallSession = findNestedCallSession(args[i]);
|
||||
final PsiExpression arg = PsiUtil.skipParenthesizedExprDown(args[i]);
|
||||
if (arg != null) {
|
||||
final InferenceSession nestedCallSession = findNestedCallSession(arg);
|
||||
final PsiType parameterType =
|
||||
nestedCallSession.substituteWithInferenceVariables(getParameterType(parameters, i, siteSubstitutor, varargs));
|
||||
if (!isPertinentToApplicability(args[i], parentMethod)) {
|
||||
additionalConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
|
||||
if (!isPertinentToApplicability(arg, parentMethod)) {
|
||||
additionalConstraints.add(new ExpressionCompatibilityConstraint(arg, parameterType));
|
||||
}
|
||||
additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(args[i], parameterType));
|
||||
if (args[i] instanceof PsiCallExpression && PsiPolyExpressionUtil.isPolyExpression(args[i])) {
|
||||
additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(arg, parameterType));
|
||||
if (arg instanceof PsiCallExpression && PsiPolyExpressionUtil.isPolyExpression(arg)) {
|
||||
//If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12),
|
||||
//the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
|
||||
final PsiCallExpression callExpression = (PsiCallExpression)args[i];
|
||||
final PsiCallExpression callExpression = (PsiCallExpression)arg;
|
||||
collectAdditionalConstraints(additionalConstraints, callExpression);
|
||||
} else if (args[i] instanceof PsiLambdaExpression && toplevel) {
|
||||
collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)args[i], parameterType);
|
||||
} else if (arg instanceof PsiLambdaExpression && toplevel) {
|
||||
collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)arg, parameterType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
abstract class Test {
|
||||
public List<Integer> gerFirstTriangles() {
|
||||
return flatMap((y -> (map((z1 -> (1)))))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
abstract <R> R flatMap(Function<Integer, R> mapper);
|
||||
abstract <R> Stream<R> map (Function<Integer, R> mapper);
|
||||
}
|
||||
+4
@@ -117,6 +117,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testParenthesizedExpressionsDuringConstrainsCollection() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user