IDEA-242422 ArrayIndexOutOfBoundsException in FunExprOccurrence

GitOrigin-RevId: d0b1b4e881c919d9e855f897452c371dd12f2a59
This commit is contained in:
Peter Gromov
2020-06-03 15:56:48 +03:00
committed by intellij-monorepo-bot
parent 1802cec4d9
commit 29ef77afd0
3 changed files with 19 additions and 1 deletions
@@ -133,7 +133,7 @@ public class FunExprOccurrence {
private boolean isCompatible(ReferenceChainLink link, PsiMember member, List<? extends PsiClass> samClasses) {
if (link.isCall) {
return member instanceof PsiMethod && hasCompatibleParameter((PsiMethod)member, argIndex, samClasses);
return member instanceof PsiMethod && argIndex >= 0 && hasCompatibleParameter((PsiMethod)member, argIndex, samClasses);
}
if (member instanceof PsiClass) {
return samClasses.contains(member);
@@ -0,0 +1,12 @@
class A {
{
bar() = () -> {};;
}
I bar() {}
}
interface I {
void run();
}
@@ -252,6 +252,12 @@ public class FindFunctionalInterfaceTest extends LightJavaCodeInsightFixtureTest
assertOneElement(FunctionalExpressionSearch.search(fooClasses[1]).findAll());
}
public void testInvalidCode() {
configure();
// whatever, but it shouldn't throw
assertEmpty(FunctionalExpressionSearch.search(findClass("I")).findAll());
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/lambda/findUsages/";