redundant cast: nested casts with outer primitive (IDEA-119857)

This commit is contained in:
Anna Kozlova
2014-04-14 18:51:29 +02:00
parent f3bc48e888
commit f20f1bb8cf
4 changed files with 28 additions and 1 deletions
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,20 @@
class TestCasting
{
public void testRedundantCast() throws Exception
{
Object o = getObject();
double d = 0.0;
if( o instanceof Integer )
{
d = (double) (Integer)o;
}
System.out.println( "d = " + d );
}
private Object getObject()
{
return new Integer(42);
}
}
@@ -57,6 +57,11 @@ public class RedundantCast15Test extends InspectionTestCase {
doTest();
}
public void testBoxingTopCast() throws Exception {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), getTestRootDisposable());
doTest();
}
public void testIgnore() throws Exception {
final RedundantCastInspection castInspection = new RedundantCastInspection();
castInspection.IGNORE_ANNOTATED_METHODS = true;