mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
ensure left expression is processed before right in assignments (IDEA-140772)
This commit is contained in:
@@ -1262,13 +1262,12 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
myStartStatementStack.pushStatement(expression.getRExpression() == null ? expression : expression.getRExpression(), false);
|
||||
myEndStatementStack.pushStatement(expression.getRExpression() == null ? expression : expression.getRExpression(), false);
|
||||
|
||||
PsiExpression rExpr = expression.getRExpression();
|
||||
if (rExpr != null) {
|
||||
rExpr.accept(this);
|
||||
}
|
||||
|
||||
PsiExpression lExpr = PsiUtil.skipParenthesizedExprDown(expression.getLExpression());
|
||||
if (lExpr instanceof PsiReferenceExpression) {
|
||||
PsiExpression rExpr = expression.getRExpression();
|
||||
if (rExpr != null) {
|
||||
rExpr.accept(this);
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)lExpr;
|
||||
PsiExpression qualifierExpression = referenceExpression.getQualifierExpression();
|
||||
PsiVariable variable = getUsedVariable(referenceExpression);
|
||||
@@ -1293,6 +1292,10 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
}
|
||||
else if (lExpr != null) {
|
||||
lExpr.accept(this);
|
||||
PsiExpression rExpr = expression.getRExpression();
|
||||
if (rExpr != null) {
|
||||
rExpr.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
myStartStatementStack.popStatement();
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
int i;
|
||||
int[] iA = {10,20};
|
||||
iA[<error descr="Variable 'i' might not have been initialized">i</error>] = i = 30;
|
||||
}
|
||||
}
|
||||
+4
@@ -63,4 +63,8 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testAgentPremain() {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testInitializedBeforeUsed() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user