mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
do not add conditional goto switch end when no default label present but all enum constants were mentioned (IDEA-68872)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>72</line>
|
||||
<description>Method invocation <code>foo.length()</code> may produce <code>java.lang.NullPointerException</code></description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1,78 @@
|
||||
public class Test {
|
||||
void withDefaultWithoutBreak(MyEnum e) {
|
||||
String foo = null;
|
||||
switch (e) {
|
||||
case FOO:
|
||||
foo = "foo";
|
||||
case BAR:
|
||||
foo = "bar";
|
||||
default:
|
||||
foo = "default";
|
||||
}
|
||||
int l = foo.length();
|
||||
}
|
||||
|
||||
void withDefaultWithBreak(MyEnum e) {
|
||||
String foo = null;
|
||||
switch (e) {
|
||||
case FOO:
|
||||
foo = "foo";
|
||||
break;
|
||||
case BAR:
|
||||
foo = "bar";
|
||||
break;
|
||||
default:
|
||||
foo = "default";
|
||||
}
|
||||
int l = foo.length();
|
||||
}
|
||||
|
||||
void withDefaultWithoutBar(MyEnum e) {
|
||||
String foo = null;
|
||||
switch (e) {
|
||||
case FOO:
|
||||
foo = "foo";
|
||||
break;
|
||||
default:
|
||||
foo = "default";
|
||||
}
|
||||
int l = foo.length();
|
||||
}
|
||||
|
||||
void withoutDefaultWithBreak(MyEnum e) {
|
||||
String foo = null;
|
||||
switch (e) {
|
||||
case FOO:
|
||||
foo = "foo";
|
||||
break;
|
||||
case BAR:
|
||||
foo = "bar";
|
||||
break;
|
||||
}
|
||||
int l = foo.length();
|
||||
}
|
||||
|
||||
void withoutDefaultWithoutBreak(MyEnum e) {
|
||||
String foo = null;
|
||||
switch (e) {
|
||||
case FOO:
|
||||
foo = "foo";
|
||||
case BAR:
|
||||
foo = "bar";
|
||||
}
|
||||
int l = foo.length();
|
||||
}
|
||||
|
||||
void withoutDefaultWithoutBar(MyEnum e) {
|
||||
String foo = null;
|
||||
switch (e) {
|
||||
case FOO:
|
||||
foo = "foo";
|
||||
}
|
||||
int l = foo.length();
|
||||
}
|
||||
}
|
||||
|
||||
enum MyEnum {
|
||||
FOO, BAR;
|
||||
}
|
||||
Reference in New Issue
Block a user