mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inference: register nested sessions for void compatible lambdas (IDEA-207070)
GitOrigin-RevId: 77f740e2754917b0053fcb79fb56e2b0c62436f4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bff61142a8
commit
81a13b0fc0
+1
-1
@@ -456,7 +456,7 @@ public class InferenceSession {
|
||||
boolean addConstraint,
|
||||
PsiSubstitutor initialSubstitutor) {
|
||||
final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(parameterType);
|
||||
if (interfaceReturnType != null && !PsiType.VOID.equals(interfaceReturnType)) {
|
||||
if (interfaceReturnType != null && (!PsiType.VOID.equals(interfaceReturnType) || !addConstraint)) {
|
||||
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions(lambdaExpression);
|
||||
for (PsiExpression returnExpression : returnExpressions) {
|
||||
processReturnExpression(additionalConstraints, ignoredConstraints, returnExpression, interfaceReturnType, addConstraint, initialSubstitutor);
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
class MyTest {
|
||||
|
||||
{
|
||||
foo(() -> build(id(x -> x)));
|
||||
}
|
||||
|
||||
static <I> I id(I i) {
|
||||
return i;
|
||||
}
|
||||
static <K> void foo(Runnable e) {}
|
||||
|
||||
static <TT> List<TT> build(Function<String, TT> transformers) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
@@ -168,6 +168,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testUnhandledExceptionInLambdaChain() { doTest(); }
|
||||
public void testFunctionalBound() { doTest(); }
|
||||
public void testValidFixesOnUnresolvedMethod() { doTest(); }
|
||||
public void testPolyExpressionInVoidCompatibleLambdaReturn() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
|
||||
Reference in New Issue
Block a user