mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IDEA-223192 Non-initialized variable error is not displayed in nested switch statement
GitOrigin-RevId: 850afa74fb22dd858bdc8ff7903946678e53d82c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
46cf985f64
commit
acb3387b1c
@@ -281,7 +281,7 @@ public class HighlightControlFlowUtil {
|
||||
PsiElement scope = variable instanceof PsiField
|
||||
? ((PsiField)variable).getContainingClass()
|
||||
: variable.getParent() != null ? variable.getParent().getParent() : null;
|
||||
if (scope instanceof PsiCodeBlock && scope.getParent() instanceof PsiSwitchStatement) {
|
||||
while (scope instanceof PsiCodeBlock && scope.getParent() instanceof PsiSwitchStatement) {
|
||||
scope = PsiTreeUtil.getParentOfType(scope, PsiCodeBlock.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -261,4 +261,21 @@ class ParenthesizedThis {
|
||||
(this).x = 5; // javac disallows this -- probably a bug in javac
|
||||
<error descr="Variable 'x' might already have been assigned to">this.x</error> = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NestedSwitch {
|
||||
public static void main(String[] args) {
|
||||
for(int i = 0; i < 8; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
switch (i+1) {
|
||||
default:
|
||||
final int var;
|
||||
<error descr="Variable 'var' might not have been initialized">var</error>++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user