mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[java] effectively final: ensure checks are performed on the same variable
GitOrigin-RevId: 77dc60e5a5119eecdd73268e192bd52390dff342
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d3f5af9da9
commit
8bb3536c11
@@ -788,7 +788,9 @@ public final class HighlightControlFlowUtil {
|
||||
codeBlock.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
if (PsiUtil.isAccessedForWriting(expression) && ControlFlowUtil.isVariableAssignedInLoop(expression, variable)) {
|
||||
if (expression.isReferenceTo(variable) &&
|
||||
PsiUtil.isAccessedForWriting(expression) &&
|
||||
ControlFlowUtil.isVariableAssignedInLoop(expression, variable)) {
|
||||
stopWalking();
|
||||
stopped.set(true);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,15 @@ public class XXX {
|
||||
int y;
|
||||
foo(() -> <error descr="Variable used in lambda expression should be final or effectively final">y</error>=1);
|
||||
}
|
||||
|
||||
void m9() {
|
||||
int x = 42;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
x = x + 42;
|
||||
}
|
||||
int y = 5;
|
||||
foo(() -> y);
|
||||
}
|
||||
}
|
||||
|
||||
class Sample {
|
||||
|
||||
Reference in New Issue
Block a user