mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
infer nullity: check for switch conditions (IDEA-61451)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user