mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
new inference: do not cache control flow during conflict resolution (IDEA-130226)
This commit is contained in:
@@ -37,6 +37,24 @@ import javax.swing.*;
|
||||
|
||||
public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements PsiLambdaExpression {
|
||||
|
||||
private static final ControlFlowPolicy ourPolicy = new ControlFlowPolicy() {
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiVariable getUsedVariable(@NotNull PsiReferenceExpression refExpr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParameterAccepted(@NotNull PsiParameter psiParameter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalVariableAccepted(@NotNull PsiLocalVariable psiVariable) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public PsiLambdaExpressionImpl() {
|
||||
super(JavaElementType.LAMBDA_EXPRESSION);
|
||||
}
|
||||
@@ -92,9 +110,7 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
final PsiElement body = getBody();
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
try {
|
||||
ControlFlow controlFlow =
|
||||
ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy
|
||||
.getInstance());
|
||||
ControlFlow controlFlow = ControlFlowFactory.getInstance(getProject()).getControlFlow(body, ourPolicy);
|
||||
int startOffset = controlFlow.getStartOffset(body);
|
||||
int endOffset = controlFlow.getEndOffset(body);
|
||||
if (startOffset != -1 && endOffset != -1 && ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset)) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
{
|
||||
queryForObject(
|
||||
(rs) -> {
|
||||
try {
|
||||
return readValue(rs);
|
||||
} catch (IOException e) {
|
||||
return new UserOptions();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
UserOptions readValue(String content) throws IOException {
|
||||
System.out.println(content);
|
||||
return null;
|
||||
}
|
||||
|
||||
UserOptions readValue(Integer i) throws IOException {
|
||||
System.out.println(i);
|
||||
return null;
|
||||
}
|
||||
|
||||
void queryForObject(Mapper rowMapper) {
|
||||
System.out.println(rowMapper);
|
||||
}
|
||||
|
||||
void queryForObject(String requiredType) {
|
||||
System.out.println(requiredType);
|
||||
}
|
||||
|
||||
interface Mapper {
|
||||
UserOptions mapRow(String rs) throws IOException;
|
||||
}
|
||||
|
||||
class UserOptions {}
|
||||
|
||||
}
|
||||
@@ -42,6 +42,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testVoidValueCompatibilityOfImplicitlyTypedLambda() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVoidValueCompatibilityCachedControlFlow() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA102800() throws Exception {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user