[java-inspections] RedundantCastInspection: recheck that the cast is redundant in fix

This might be important if 'fix all' is applied and two casts are redundant individually, but not together

GitOrigin-RevId: 90e26e9e1a04a88ef50bb87e2f981c4ee1c154f1
This commit is contained in:
Tagir Valeev
2025-05-26 13:10:59 +02:00
committed by intellij-monorepo-bot
parent ec528f9f08
commit ddc812cd28

View File

@@ -125,7 +125,7 @@ public final class RedundantCastInspection extends AbstractBaseJavaLocalInspecti
@Override
protected void applyFix(@NotNull Project project, @NotNull PsiElement castTypeElement, @NotNull ModPsiUpdater updater) {
if (castTypeElement.getParent() instanceof PsiTypeCastExpression cast) {
if (castTypeElement.getParent() instanceof PsiTypeCastExpression cast && RedundantCastUtil.isCastRedundant(cast)) {
RemoveRedundantCastUtil.removeCast(cast);
}
}