mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] More precise fix for IDEA-370768
GitOrigin-RevId: 1f5f2d2076b3eecaf173ba4604c3ba8ab27dd281
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4be8958b3f
commit
30cb09e0c9
@@ -320,7 +320,9 @@ public final class RedundantCastUtil {
|
||||
|
||||
JavaResolveResult newResult = newExpression.advancedResolve(false);
|
||||
if (!newResult.isValidResult() || !oldMember.equals(newResult.getElement())) return false;
|
||||
if (!Objects.equals(newExpression.getType(), refExpression.getType())) return false;
|
||||
PsiType expected = ExpectedTypeUtils.findExpectedType(refExpression, false);
|
||||
PsiType actual = newExpression.getType();
|
||||
if (expected == null || actual == null || !TypeConversionUtil.isAssignable(expected, actual)) return false;
|
||||
if (parent instanceof PsiReferenceExpression parentRef && !newResult.getSubstitutor().equals(resolveResult.getSubstitutor())) {
|
||||
return isCastInReferenceQualifierRedundant(parentRef);
|
||||
}
|
||||
|
||||
@@ -6,4 +6,8 @@ class B extends A<String> {
|
||||
static String test(A<?> b) {
|
||||
return ((B) b).value;
|
||||
}
|
||||
|
||||
static Object test1(A<?> b) {
|
||||
return ((<warning descr="Casting 'b' to 'B' is redundant">B</warning>) b).value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user