mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
new inference: fix isPertinent for implicit typed lambdas
This commit is contained in:
@@ -103,7 +103,7 @@ public class InferenceSession {
|
||||
|
||||
public static boolean isPertinentToApplicability(PsiExpression expr, PsiMethod method) {
|
||||
if (expr instanceof PsiLambdaExpression) {
|
||||
if (((PsiLambdaExpression)expr).hasFormalParameterTypes()) return true;
|
||||
if (!((PsiLambdaExpression)expr).hasFormalParameterTypes()) return false;
|
||||
for (PsiExpression expression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)expr)) {
|
||||
if (!isPertinentToApplicability(expression, method)) return false;
|
||||
}
|
||||
|
||||
@@ -82,22 +82,22 @@ public class PsiPolyExpressionUtilTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testPertinentLambdaExpression() throws Exception {
|
||||
assertTrue(doTestLambdaPertinent(" void bar(List<Runnable> l) {" +
|
||||
assertFalse(doTestLambdaPertinent(" void bar(List<Runnable> l) {" +
|
||||
" foo(() <caret>-> {}, l);" +
|
||||
" }"));
|
||||
}
|
||||
|
||||
public void testPertinentImplicitLambdaExpression() throws Exception {
|
||||
assertTrue(doTestLambdaPertinent(" void bar(List<Comparable<String>> l) {" +
|
||||
" foo((String s) <caret>-> 1, l);" +
|
||||
" }"));
|
||||
assertFalse(doTestLambdaPertinent(" void bar(List<Comparable<String>> l) {" +
|
||||
" foo((String s) <caret>-> 1, l);" +
|
||||
" }"));
|
||||
}
|
||||
|
||||
public void testPertinentNestedLambdaExpression() throws Exception {
|
||||
assertTrue(doTestLambdaPertinent(" interface Fun<I, O> { O inOut(I i);}\n" +
|
||||
" void bar(List<Fun<String, Fun<String, String>>> l) {" +
|
||||
" foo((sIn, sOut) -> (sInInner, sOutInner) <caret>-> sOutInner, l);" +
|
||||
" }"));
|
||||
assertFalse(doTestLambdaPertinent(" interface Fun<I, O> { O inOut(I i);}\n" +
|
||||
" void bar(List<Fun<String, Fun<String, String>>> l) {" +
|
||||
" foo((sIn, sOut) -> (sInInner, sOutInner) <caret>-> sOutInner, l);" +
|
||||
" }"));
|
||||
}
|
||||
|
||||
private boolean doTestLambdaPertinent(final String barText) {
|
||||
|
||||
Reference in New Issue
Block a user