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:
anna
2011-06-03 17:59:04 +04:00
parent 0e416a207b
commit 48e81bb6c1
4 changed files with 108 additions and 4 deletions
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>72</line>
<description>Method invocation &lt;code&gt;foo.length()&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;</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;
}