diff --git a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java index c6d83adc9d28..1c99e3e592e9 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java @@ -794,8 +794,6 @@ 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; } final PsiExpression stripParenthesisOperand = PsiUtil.skipParenthesizedExprDown(operand); diff --git a/java/java-tests/testData/inspection/redundantCast/lambda/CastToRawType.java b/java/java-tests/testData/inspection/redundantCast/lambda/CastToRawType.java new file mode 100644 index 000000000000..dd3a8484d445 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantCast/lambda/CastToRawType.java @@ -0,0 +1,17 @@ +import java.util.Map; + +class Main { + private final Map> myBreakpointsDefaults = null; + + @SuppressWarnings("unchecked") + public BreakpointState foo1(String type, BreakpointState defaults) { + return (BreakpointState) myBreakpointsDefaults.computeIfAbsent(type, k -> defaults); + } + + public BreakpointState foo2(String type, BreakpointState defaults) { + return (BreakpointState) myBreakpointsDefaults.computeIfAbsent(type, k -> defaults); + } + + private static class BreakpointState {} + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java index f40ccd8671c3..731c4634351c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java @@ -41,4 +41,5 @@ public class RedundantCast18Test extends LightDaemonAnalyzerTestCase { public void testForeachValue() throws Exception { doTest(); } public void testConditional() throws Exception { doTest(); } public void testInferApplicabilityError() throws Exception { doTest(); } + public void testCastToRawType() throws Exception { doTest(); } } \ No newline at end of file