don't fail to attach fixes on invalid code

EA-122929 - IOE: PsiJavaParserFacadeImpl.createExpressionFromText
This commit is contained in:
Anna.Kozlova
2018-07-16 10:43:52 +02:00
parent 02bcd73886
commit 378ea0e334
3 changed files with 13 additions and 1 deletions
@@ -812,7 +812,7 @@ public class LambdaUtil {
return (PsiCall)anEnum.add(call);
}
PsiType type = PsiTypesUtil.getExpectedTypeByParent(call);
if (type != null) {
if (type != null && PsiTypesUtil.isDenotableType(type, call)) {
return (PsiCall)copyWithExpectedType(call, type);
}
return (PsiCall)call.copy();
@@ -0,0 +1,11 @@
class MyTest {
void m(String[] refInfos){
refInfos = <error descr="Cannot resolve method 'unresolved(java.lang.String[], <lambda expression>)'">unresolved</error>(refInfos, refInfo -> {
refInfo = n<error descr="'n(java.lang.String)' in 'MyTest' cannot be applied to '(<lambda parameter>)'">(refInfo)</error>;
return refInfo;
});
}
private static String n(String refInfo) {
return refInfo;
}
}
@@ -167,6 +167,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testConditionalBooleanAsFunctionalInterfaceType() { doTest(); }
public void testUnhandledExceptionInLambdaChain() { doTest(); }
public void testFunctionalBound() { doTest(); }
public void testValidFixesOnUnresolvedMethod() { doTest(); }
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());