diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java index c32728abdd13..23aa3dce5768 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java @@ -82,22 +82,18 @@ public class RedundantThrowsDeclarationLocalInspection extends AbstractBaseJavaL if (candidates.isEmpty()) return null; if (needCheckOverridingMethods) { - - Set thrownExceptionShortNames = candidates.stream().map(refAndType -> refAndType.type.getClassName()).collect(Collectors.toSet()); - Predicate methodContainsThrownExceptions = m -> Arrays.stream(m.getThrowsList().getReferencedTypes()) - .map(PsiClassType::getClassName) - .anyMatch(thrownExceptionShortNames::contains); + Predicate methodContainsThrownExceptions = m -> m.getThrowsList().getReferencedTypes().length != 0; Stream overridingMethods = JavaOverridingMethodUtil.getOverridingMethodsIfCheapEnough(method, null, methodContainsThrownExceptions); if (overridingMethods == null) return null; Iterator overridingMethodIt = overridingMethods.iterator(); while (overridingMethodIt.hasNext()) { PsiMethod m = overridingMethodIt.next(); - PsiClassType[] overridingMethodThrownException = m.getThrowsList().getReferencedTypes(); + PsiClassType[] overridingMethodThrownExceptions = m.getThrowsList().getReferencedTypes(); candidates.removeIf(refAndType -> { PsiClassType type = refAndType.type; - return ArrayUtil.contains(type, overridingMethodThrownException); + return Arrays.stream(overridingMethodThrownExceptions).anyMatch(type::isAssignableFrom); }); if (candidates.isEmpty()) return null;