redundant casts: skip casts in conditional branches of calls when resulted call would resolve to another method (IDEA-15720)

This commit is contained in:
anna
2011-09-01 19:07:48 +02:00
parent 6b411756ea
commit 4fddb0a5c8
4 changed files with 65 additions and 3 deletions
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>A.java</file>
<line>4</line>
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant type cast</problem_class>
<description>Casting &lt;code&gt;param&lt;/code&gt; to &lt;code&gt;Object&lt;/code&gt; is redundant</description>
</problem>
</problems>
@@ -0,0 +1,10 @@
class A {
void add(Object o, String param) {
add(o, o != null ? null : (Object) param);
add(o, o == null ? new Object() : (Object) param);
}
void add(Object o, Object param) {
}
}
@@ -91,4 +91,6 @@ public class RedundantCastTest extends InspectionTestCase {
public void testNestedCast() throws Exception { doTest(); }
public void testPrimitiveInsideSynchronized() throws Exception { doTest(); }
public void testInConditionalPreserveResolve() throws Exception { doTest();}
}