mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix SOE in groovy control flow building (EA-39132,EA-39133)
This commit is contained in:
+11
-7
@@ -382,12 +382,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
addNodeAndCheckPending(throwInstruction);
|
||||
|
||||
interruptFlow();
|
||||
final PsiType type = RecursionManager.doPreventingRecursion(exception, true, new NullableComputable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
return exception.getNominalType();
|
||||
}
|
||||
});
|
||||
final PsiType type = getNominalTypeNoRecursion(exception);
|
||||
if (type != null) {
|
||||
ExceptionInfo info = findCatch(type);
|
||||
if (info != null) {
|
||||
@@ -402,6 +397,15 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
private static PsiType getNominalTypeNoRecursion(final GrExpression exception) {
|
||||
return RecursionManager.doPreventingRecursion(exception, true, new NullableComputable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
return exception.getNominalType();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void interruptFlow() {
|
||||
myHead = null;
|
||||
}
|
||||
@@ -924,7 +928,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
final GrExpression condition = statement.getCondition();
|
||||
if (!(condition instanceof GrReferenceExpression)) return false;
|
||||
|
||||
PsiType type = TypesUtil.unboxPrimitiveTypeWrapper(condition.getNominalType());
|
||||
PsiType type = TypesUtil.unboxPrimitiveTypeWrapper(getNominalTypeNoRecursion(condition));
|
||||
if (type == null) return false;
|
||||
|
||||
if (type instanceof PsiPrimitiveType) {
|
||||
|
||||
@@ -1419,4 +1419,19 @@ class X {
|
||||
testHighlighting('''\
|
||||
def (a, b) = [a, a]''')
|
||||
}
|
||||
|
||||
public void testSwitchInLoopNoSoe() {
|
||||
testHighlighting('''
|
||||
def foo(File f) {
|
||||
while (true) {
|
||||
switch (f.name) {
|
||||
case 'foo': f = new File('bar')
|
||||
}
|
||||
if (f) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}''')
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user