redundant cast: don't mark redundant boxing casts in conditional (IDEA-137395)

This commit is contained in:
Anna Kozlova
2015-06-26 20:30:56 +03:00
parent c0fac12ef9
commit f38a38278c
3 changed files with 31 additions and 0 deletions
@@ -6,4 +6,11 @@
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant type cast</problem_class>
<description>Casting &lt;code&gt;2&lt;/code&gt; to &lt;code&gt;Integer&lt;/code&gt; is redundant</description>
</problem>
<problem>
<file>Test.java</file>
<line>18</line>
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant type cast</problem_class>
<description>Casting &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;Integer&lt;/code&gt; is redundant</description>
</problem>
</problems>
@@ -7,4 +7,16 @@ public class Test {
private int foo1(String s, Integer i) {
return s == null ? i : (Integer)2;
}
}
class RedundantCastTest {
public static void main(String[] args) {
Integer foo = 5;
Integer bar = null;
print(args == null || args.length == 0 ? bar : (Integer) 1);
int i = args == null || args.length == 0 ? bar : (Integer) 1;
}
private static void print(Integer i) {}
}