mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-21 20:54:49 +07:00
Now we visit switch default branch, even if it's reachable only on added enum constant This fixes IDEA-227734 Data flow inspection doesn't report return null inside a switch for @NotNull annotated method Also if-chains and switch are processed more uniformly: if we replace exhaustive switch statement with the equivalent if, we won't get possible NPE anymore GitOrigin-RevId: c090b9e76a31a4626b518461b1b4ffce8cd3a7aa
38 lines
871 B
Java
38 lines
871 B
Java
import org.jetbrains.annotations.*;
|
|
|
|
// IDEA-227734
|
|
class Test {
|
|
enum MyEnum{ A, B, C }
|
|
|
|
@NotNull
|
|
String doesNotShowWarning(@NotNull MyEnum myEnum){
|
|
switch(myEnum){
|
|
case A:
|
|
case B:
|
|
case C:
|
|
return "YES";
|
|
default: return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
|
|
}
|
|
}
|
|
|
|
@NotNull
|
|
String doesNotShowWarning2(@NotNull final MyEnum myEnum){
|
|
switch(myEnum){
|
|
case A:
|
|
case B:
|
|
case C:
|
|
return "YES";
|
|
}
|
|
return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
|
|
}
|
|
|
|
@NotNull
|
|
String showsWarning(@NotNull MyEnum myEnum){
|
|
switch(myEnum){
|
|
case A:
|
|
case B:
|
|
return "YES";
|
|
default: return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
|
|
}
|
|
}
|
|
} |