In the the following method, the Idea editor correctly reports "condition foo != null is always true":
public void bar(@NotNull Object foo)
{
assert foo != null;
// try
// {
//
// }
// catch (NumberFormatException ex)
// {//// } }
}
However, if I uncomment the try..catch block in the above method, Idea incorrectly omits the warning on the assert statement. This seems quite repeatable.
This appears to be a clear bug in the Idea data flow tracing code. Interestingly, if the catch block is changed to catch type Exception rather than a RuntimeException-derived type, the warning message reappears.
Version A:
public void bar(@NotNull Object foo)
{ assert foo != null; }Version B:
public void bar(@NotNull Object foo)
{
assert foo != null;
try
{
}
catch (NumberFormatException ex)
{
}
}