mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda valueCompatible check: don't evaluate constant expressions which could lead to reference resolution during overload check = caching possible wrong refs (IDEA-141808)
This commit is contained in:
+1
-1
@@ -110,7 +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, ourPolicy);
|
||||
ControlFlow controlFlow = ControlFlowFactory.getInstance(getProject()).getControlFlow(body, ourPolicy, false, false);
|
||||
int startOffset = controlFlow.getStartOffset(body);
|
||||
int endOffset = controlFlow.getEndOffset(body);
|
||||
if (startOffset != -1 && endOffset != -1 && ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset)) {
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
class Test {
|
||||
class Message<T> {
|
||||
public T data;
|
||||
}
|
||||
|
||||
class Result<<warning descr="Type parameter 'T' is never used">T</warning>> {
|
||||
public boolean isSuccessful() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
interface handlerReturn<R, T> {
|
||||
R process(T m);
|
||||
}
|
||||
private <R, T> void <warning descr="Private method 'process(Test.handlerReturn<R,T>)' is never used">process</warning>(handlerReturn<R, T> <warning descr="Parameter 'h' is never used">h</warning>) {}
|
||||
|
||||
interface handler<T> {
|
||||
void process(T m);
|
||||
}
|
||||
private <T> void process(handler<T> <warning descr="Parameter 'h' is never used">h</warning>) {}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Test t = new Test();
|
||||
t.<Message<Result<String>>>process(m -> {
|
||||
if (m.data.isSuccessful());
|
||||
});
|
||||
}
|
||||
}
|
||||
+4
@@ -126,6 +126,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDoNotCheckConstantIfsDuringValueCompatibleChecks() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user