From 630b34c4665216842c1d2f1805ce989aed5fec41 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 28 Jun 2011 17:10:12 +0400 Subject: [PATCH] redundant cast: do not mark casts to raw types redundant (IDEA-71419) --- .../redundantCast/generics/RawCast/src/Test.java | 10 ++++++++++ .../src/com/intellij/psi/util/RedundantCastUtil.java | 2 ++ 2 files changed, 12 insertions(+) diff --git a/java/java-tests/testData/inspection/redundantCast/generics/RawCast/src/Test.java b/java/java-tests/testData/inspection/redundantCast/generics/RawCast/src/Test.java index 2039039b8691..c38a855aca88 100644 --- a/java/java-tests/testData/inspection/redundantCast/generics/RawCast/src/Test.java +++ b/java/java-tests/testData/inspection/redundantCast/generics/RawCast/src/Test.java @@ -1,3 +1,4 @@ +import java.util.List; import java.util.Map; import java.util.Properties; @@ -9,3 +10,12 @@ public class Main { System.out.println(map); } } + +interface I {} +class C implements I {} +class U { + void foo() { + List listOfC = null; + List listOfI = (List) listOfC; + } +} diff --git a/java/openapi/src/com/intellij/psi/util/RedundantCastUtil.java b/java/openapi/src/com/intellij/psi/util/RedundantCastUtil.java index 236e16beea13..15f928500624 100644 --- a/java/openapi/src/com/intellij/psi/util/RedundantCastUtil.java +++ b/java/openapi/src/com/intellij/psi/util/RedundantCastUtil.java @@ -447,6 +447,8 @@ public class RedundantCastUtil { } else if (castType instanceof PsiClassType && ((PsiClassType)castType).hasParameters()) { if (opType instanceof PsiClassType && ((PsiClassType)opType).isRaw()) return true; + } else if (castType instanceof PsiClassType && ((PsiClassType)castType).isRaw()) { + if (opType instanceof PsiClassType && ((PsiClassType)opType).hasParameters()) return true; } PsiElement parent = typeCast.getParent();