mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
lambda isValueCompatible check: ensure throws is not treated as normal completion (IDEA-135581)
This commit is contained in:
@@ -731,7 +731,8 @@ public class ControlFlowUtil {
|
||||
|
||||
if (nextOffset == endOffset) {
|
||||
final Instruction lastInstruction = flow.getInstructions().get(endOffset - 1);
|
||||
isNormal = !(lastInstruction instanceof GoToInstruction && ((GoToInstruction)lastInstruction).isReturn);
|
||||
isNormal = !(lastInstruction instanceof GoToInstruction && ((GoToInstruction)lastInstruction).isReturn) &&
|
||||
!(lastInstruction instanceof ThrowToInstruction);
|
||||
}
|
||||
|
||||
isNormal |= throwToOffset <= endOffset && !isLeaf(nextOffset) && canCompleteNormally[nextOffset];
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
method(() -> {
|
||||
if (check(args[0])) {
|
||||
return "";
|
||||
} else {
|
||||
throw new Exception("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> void method(Callable<T> callable) {}
|
||||
public static boolean check(String s) throws Exception {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testValueCompatibleWithThrowsStatement() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testIDEA102800() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user