Commit b8b39546 authored by Anna Kozlova's avatar Anna Kozlova Committed by intellij-monorepo-bot
Browse files

IDEA-CR-55024: java inference: ease assertion for lambdas in non-generic calls (EA-143883)

(cherry picked from commit 0e5ff0aa54375926c8ea5e2140458457250034dc)

GitOrigin-RevId: e8b0f6723141e77c2dade37f08458eb7f794ab8b
parent 47088d66
Branches unavailable Tags unavailable
No related merge requests found
Showing with 30 additions and 1 deletion
+30 -1
......@@ -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);
}
}
......
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;
}
}
......@@ -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 =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment