mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda inference: conditional expressions in returns (IDEA-174301)
skip conditionals and parenthesis during find top expression
This commit is contained in:
+3
@@ -165,6 +165,9 @@ public class InferenceSessionContainer {
|
||||
gParent = returnContainer.getParent();
|
||||
}
|
||||
}
|
||||
if (gParent instanceof PsiConditionalExpression) {
|
||||
gParent = PsiUtil.skipParenthesizedExprUp(gParent.getParent());
|
||||
}
|
||||
if (gParent instanceof PsiLambdaExpression) {
|
||||
final PsiCall call = PsiTreeUtil.getParentOfType(gParent, PsiCall.class);
|
||||
if (call != null) {
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
interface Container<T> {
|
||||
static <Q> Function<Q, Container<Q>> typeTester(Container<Q> c, final Container<Q> one) {
|
||||
return funcWithString(input -> c.match(aa -> (true ? (zero()) : one)));
|
||||
}
|
||||
|
||||
static <S> Function<S, Container<S>> funcWithString(Function<S, Container<S>> f) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default <R> R match(Function<T, R> f) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T> Container<T> zero() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
@@ -158,6 +158,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIgnoreStandaloneExpressionsInLambdaReturnForNestedCalls() { doTest(); }
|
||||
public void testArrayNotAFunctionalInterface() { doTest(); }
|
||||
public void testRawSubstitutionForInterfaceMethod() { doTest(); }
|
||||
public void testConditionalExpressionInLambdaReturns() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
|
||||
Reference in New Issue
Block a user