mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] dfa: handle conditions within instanceof (IDEA-171182)
This commit is contained in:
+2
@@ -632,6 +632,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
}
|
||||
|
||||
private void processInstanceOf(GrExpression expression) {
|
||||
FList<ConditionInstruction> conditionsBefore = myConditions;
|
||||
ConditionInstruction cond = registerCondition(expression);
|
||||
addNodeAndCheckPending(cond);
|
||||
|
||||
@@ -643,6 +644,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
|
||||
myHead = cond;
|
||||
addNode(new InstanceOfInstruction(expression, cond));
|
||||
myConditions = conditionsBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
@@ -789,4 +789,15 @@ def foo(List list) {
|
||||
doExprTest '[foo: 2, bar: 4]*.value', 'java.util.ArrayList<java.lang.Integer>'
|
||||
doExprTest '[foo: 2, bar: 4]*.undefined', 'java.util.List'
|
||||
}
|
||||
|
||||
void 'test instanceof does not interfere with outer if'() {
|
||||
doTest '''\
|
||||
def bar(CharSequence xx) {
|
||||
if (xx instanceof String) {
|
||||
1 instanceof Object
|
||||
<caret>xx
|
||||
}
|
||||
}
|
||||
''', 'java.lang.String'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ else b = 3
|
||||
7(8) WRITE b
|
||||
8(22) element: Assignment expression MAYBE_RETURN
|
||||
9(10) element: IF statement
|
||||
10(11) Condition Unary expression, dependent: 3
|
||||
10(11) Condition Unary expression
|
||||
11(12) READ o
|
||||
12(13,15) Condition Instanceof expression, dependent: 10, 3
|
||||
12(13,15) Condition Instanceof expression, dependent: 10
|
||||
13(14) instanceof: o instanceof Integer
|
||||
14(17) Negating goto instruction, condition=12Instanceof expression
|
||||
15(16) instanceof: o instanceof Integer
|
||||
|
||||
Reference in New Issue
Block a user