mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
can complete normally for nested try-with-resources (IDEA-138961)
This commit is contained in:
@@ -732,19 +732,23 @@ public class ControlFlowUtil {
|
||||
if (nextOffset == endOffset) {
|
||||
int lastOffset = endOffset - 1;
|
||||
Instruction lastInstruction = flow.getInstructions().get(lastOffset);
|
||||
if (lastInstruction instanceof GoToInstruction &&
|
||||
while (lastInstruction instanceof GoToInstruction &&
|
||||
((GoToInstruction)lastInstruction).role == BranchingInstruction.Role.END &&
|
||||
!((GoToInstruction)lastInstruction).isReturn) {
|
||||
if (((GoToInstruction)lastInstruction).offset == startOffset) {
|
||||
lastOffset = -1;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
lastOffset--;
|
||||
if (lastOffset < 0) {
|
||||
break;
|
||||
}
|
||||
lastInstruction = flow.getInstructions().get(lastOffset);
|
||||
}
|
||||
}
|
||||
|
||||
if (lastOffset >= 0) {
|
||||
lastInstruction = flow.getInstructions().get(lastOffset);
|
||||
isNormal = !(lastInstruction instanceof GoToInstruction && ((GoToInstruction)lastInstruction).isReturn) &&
|
||||
!(lastInstruction instanceof ThrowToInstruction);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
class Test {
|
||||
Database database;
|
||||
|
||||
Set<Long> getItems() {
|
||||
return database.perform(connection -> {
|
||||
try (AutoCloseable c = null) {
|
||||
try (AutoCloseable d = null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface Database {
|
||||
<V> V perform(BusinessLogic<V> logic);
|
||||
}
|
||||
|
||||
public interface BusinessLogic<V> {
|
||||
V execute(String connection) throws Exception;
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLambdaValueCompatibleWithNestedTryWithResources() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testManyOverloadsWithVarargs() throws Exception {
|
||||
PlatformTestUtil.startPerformanceTest("Overload resolution with 14 overloads", 20000, new ThrowableRunnable() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user