infer nullity: check for switch conditions (IDEA-61451)

This commit is contained in:
anna
2010-12-13 20:57:59 +03:00
parent daaee7acc2
commit 1c515125bb
4 changed files with 34 additions and 0 deletions
@@ -578,6 +578,10 @@ public class NullityInferrer {
return true;
}
}
else if (parent instanceof PsiSwitchStatement && ((PsiSwitchStatement)parent).getExpression() == expr) {
registerNotNullAnnotation(parameter);
return true;
}
final PsiCall call = PsiTreeUtil.getParentOfType(expr, PsiCall.class);
if (call != null) {
@@ -0,0 +1,13 @@
import org.jetbrains.annotations.*;
public class Infer {
enum E {;
}
void trySwitchEnum(@NotNull E e) {
switch (e) {
}
}
}
@@ -0,0 +1,13 @@
import org.jetbrains.annotations.*;
public class Infer {
enum E {;
}
void trySwitchEnum(E e) {
switch (e) {
}
}
}
@@ -66,6 +66,10 @@ public class NullityInferrerTest extends CodeInsightTestCase {
doTest(true);
}
public void testTryEnumSwitch() throws Exception {
doTest(true);
}
//-----------------------fields---------------------------------------------------
public void testFieldsAssignment() throws Exception {
doTest(false);