mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
[java-highlighting] IDEA-324880 Exhaustive switches can produce definitely assigned variables
GitOrigin-RevId: 7e644a2565803fdd900830d986dba481aeb127db
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ff09dfa2e1
commit
5237df5eb3
@@ -216,4 +216,26 @@ class C {
|
||||
}
|
||||
System.out.println(<error descr="Variable 's' might not have been initialized">s</error>);
|
||||
}
|
||||
|
||||
sealed interface T permits T1, T2 {}
|
||||
final class T1 implements T {}
|
||||
final class T2 implements T {}
|
||||
|
||||
private void testStatement1(T obj) {
|
||||
int i;
|
||||
switch (obj) {
|
||||
case T1 t1 -> i = 1;
|
||||
case T2 t2 -> i = 2;
|
||||
};
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
private void testStatement2(int obj) {
|
||||
int i;
|
||||
switch (obj) {
|
||||
case 1 -> i = 1;
|
||||
case 2 -> i = 2;
|
||||
};
|
||||
System.out.println(<error descr="Variable 'i' might not have been initialized">i</error>);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user