mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java redundant cast: keep same conditional expression type based on cast type & opposite operand (IDEA-235896)
GitOrigin-RevId: 7e454f0db256ad843c7abb890953c8d264af0257
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0ed0e007ee
commit
2832d5f81c
@@ -512,8 +512,7 @@ public class RedundantCastUtil {
|
||||
final PsiExpression thenExpression = ((PsiConditionalExpression)parent).getThenExpression();
|
||||
final PsiExpression elseExpression = ((PsiConditionalExpression)parent).getElseExpression();
|
||||
final PsiExpression opposite = thenExpression == typeCast ? elseExpression : thenExpression;
|
||||
if (opposite == null || conditionalType instanceof PsiPrimitiveType &&
|
||||
!Comparing.equal(conditionalType, opposite.getType())) return;
|
||||
if (opposite == null || !Comparing.equal(conditionalType, opposite.getType())) return;
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiSynchronizedStatement &&
|
||||
|
||||
+14
@@ -6,3 +6,17 @@ class Foo {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class NonPrimitiveType {
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> void apply(Fun<Class<?>, ?> defaultGetter,
|
||||
Class<T> configType,
|
||||
Fun<Class<T>, T> getter) {
|
||||
(getter == null ? (Fun)defaultGetter : getter).apply(configType);
|
||||
}
|
||||
|
||||
interface Fun<T, R> {
|
||||
R apply(T t);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user