mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
[java-highlighting] IDEA-325375 Exhaustive switch expressions can produce definitely assigned variables. Fix type ranks
GitOrigin-RevId: 1a36f38c08e51d4cafb897a2b8ace796a74ec298
This commit is contained in:
committed by
intellij-monorepo-bot
parent
15c524d521
commit
3f18cddb20
@@ -65,6 +65,7 @@ public final class JavaPsiSwitchUtil {
|
||||
}
|
||||
|
||||
private static boolean isClassSelectorType(@NotNull PsiType type) {
|
||||
if (TypeConversionUtil.getTypeRank(type) <= TypeConversionUtil.INT_RANK) return false;
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(type)) return false;
|
||||
PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(type);
|
||||
if (psiClass != null) {
|
||||
|
||||
@@ -239,6 +239,15 @@ class C {
|
||||
System.out.println(<error descr="Variable 'i' might not have been initialized">i</error>);
|
||||
}
|
||||
|
||||
private void testStatement3(Integer 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>);
|
||||
}
|
||||
|
||||
private void testExpressions1(T obj) {
|
||||
int i;
|
||||
int y = switch (obj) {
|
||||
|
||||
Reference in New Issue
Block a user