mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java inference: ease assertion for lambdas in non-generic calls (EA-143883)
GitOrigin-RevId: 0e5ff0aa54375926c8ea5e2140458457250034dc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0000a12866
commit
eb79bfc3d3
@@ -398,8 +398,11 @@ public class LambdaUtil {
|
||||
|
||||
if (gParent instanceof PsiCall) {
|
||||
final PsiCall contextCall = (PsiCall)gParent;
|
||||
LOG.assertTrue(!MethodCandidateInfo.isOverloadCheck(contextCall.getArgumentList()));
|
||||
JavaResolveResult resolveResult = PsiDiamondType.getDiamondsAwareResolveResult(contextCall);
|
||||
PsiElement resultElement = resolveResult.getElement();
|
||||
LOG.assertTrue(!(MethodCandidateInfo.isOverloadCheck(contextCall.getArgumentList()) &&
|
||||
resultElement instanceof PsiMethod &&
|
||||
((PsiMethod)resultElement).hasTypeParameters()));
|
||||
return getSubstitutedType(expression, tryToSubstitute, lambdaIdx, resolveResult);
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import java.util.function.Function;
|
||||
|
||||
class SomeClass implements IdeaBloopers11 {
|
||||
void foo(Function<String, String> f) {}
|
||||
|
||||
void bar() {
|
||||
fo<caret>o(s -> {
|
||||
if (s.contains("a")) {
|
||||
throw baz(s);
|
||||
}
|
||||
return s;
|
||||
});
|
||||
}
|
||||
|
||||
private NullPointerException baz(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+8
@@ -57,6 +57,14 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
|
||||
assertEquals(CommonClassNames.JAVA_LANG_STRING, type.getCanonicalText());
|
||||
}
|
||||
|
||||
public void testTypeOfThrowsExpression() {
|
||||
configure();
|
||||
PsiMethodCallExpression fooCall =
|
||||
PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiMethodCallExpression.class);
|
||||
|
||||
assertNotNull(fooCall.getType());
|
||||
}
|
||||
|
||||
public void testRecursiveApplicabilityCheck() {
|
||||
configure();
|
||||
PsiMethodCallExpression getDataCall =
|
||||
|
||||
Reference in New Issue
Block a user