mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
pertinent to applicability: process return statements inside block lambda
This commit is contained in:
@@ -260,7 +260,8 @@ public class InferenceSession {
|
||||
if (isTypeParameterType(owner, paramType)) return false;
|
||||
}
|
||||
}
|
||||
else if (expectedReturnType != null && parent instanceof PsiLambdaExpression) {
|
||||
else if (expectedReturnType != null && (parent instanceof PsiLambdaExpression ||
|
||||
parent instanceof PsiReturnStatement && PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class, true, PsiMethod.class) != null)) {
|
||||
if (isTypeParameterType(method, expectedReturnType)) return false;
|
||||
paramType = expectedReturnType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Runnable iteration = compute(() -> {
|
||||
if (true) return () -> {};
|
||||
return null;
|
||||
});
|
||||
Runnable iteration2 = compute(() -> () -> {});
|
||||
}
|
||||
|
||||
static <T> T compute(Callable<T> c) throws Exception {
|
||||
return c.call();
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class NoInferenceResult {
|
||||
|
||||
void test() {
|
||||
m((String s1) -> <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>);
|
||||
m(<error descr="B is not a functional interface">(String s1) -> {return (String s2) -> s1 + s2;}</error>);
|
||||
m((String s1) -> {return <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>;});
|
||||
|
||||
m((String s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
|
||||
@@ -175,6 +175,8 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
public void testRecursiveTypeWithCapture() { doTest(); }
|
||||
public void testFreshVariablesDuringApplicabilityCheck() { doTest(); }
|
||||
|
||||
public void testPertinentToApplicabilityCheckForBlockLambda() { doTest(); }
|
||||
|
||||
public void testApplicabilityCheckFailsExpressionTypeCheckPasses() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user