assert b; warns "condition 'b' always true"; how do i suppress warning?
The code snippet
boolean b = true;
assert b;
will cause IntelliJ IDEA's introspection to produce a warning on the second line, saying that the condition b is always true. I am aware of that, that's the whole point of an assertion! I'd appreciate if that (in my opinion) bug could be fixed.
Also, is there any means of suppressing specific warnings (i.e. at a specific code place)? It seems to me that Java's @SuppressWarnings annotation only covers a small subset of all possible warnings - at least if you take IDEA's introspection warnings into account.
Tobias
请先登录再写评论。
Position the caret on the warning, press alt-enter, cursor-right and choose "Suppress for Statement".
And yes, you can use asserts when the code can be proven to satisfy the assertion anyway.
But IMHO the far more important use case is to specify assertions on method parameter values,
such as that a parameter "int age;" must be non-negative.
Tobias Thierer wrote:
http://www.jetbrains.net/jira/browse/IDEADEV-2827