mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant cast: mark raw cast as redundant when raw is expected (IDEA-162022)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.Map;
|
||||
|
||||
class Main {
|
||||
private final Map<String, BreakpointState<?,?,?>> myBreakpointsDefaults = null;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BreakpointState<String, String, String> foo1(String type, BreakpointState<?, ?, ?> defaults) {
|
||||
return (BreakpointState) myBreakpointsDefaults.computeIfAbsent(type, k -> defaults);
|
||||
}
|
||||
|
||||
public BreakpointState foo2(String type, BreakpointState<?, ?, ?> defaults) {
|
||||
return (<warning descr="Casting 'myBreakpointsDefaults.computeIfAbsent(type, k -> defaults)' to 'BreakpointState' is redundant">BreakpointState</warning>) myBreakpointsDefaults.computeIfAbsent(type, k -> defaults);
|
||||
}
|
||||
|
||||
private static class BreakpointState<A, B, C> {}
|
||||
|
||||
}
|
||||
@@ -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(); }
|
||||
}
|
||||
Reference in New Issue
Block a user