IDEA-146122 Wrong 'can produce NPE' after comparing with enum constant

This commit is contained in:
peter
2015-10-12 13:33:38 +02:00
parent 67bfef7b1d
commit af07f88aef
3 changed files with 31 additions and 1 deletions
@@ -0,0 +1,21 @@
import org.jetbrains.annotations.Nullable;
enum MyEnum {
ITEM,
ANOTHER_ITEM,
LOL_ITEM;
}
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "unused"})
class Main {
void foo(@Nullable MyEnum myEnum) {
if (myEnum == null) return;
switch (myEnum) {
case ITEM:
case ANOTHER_ITEM:
System.out.println(myEnum == MyEnum.ITEM ? "item" : "another");
myEnum.name();
default:
}
}
}