diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index 636b0331eee1..97370c856aea 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -294,9 +294,10 @@ public class HighlightMethodUtil { List checkedExceptions, PsiSubstitutor substitutorForDerivedClass) { PsiMethod superMethod = superSignature.getMethod(); PsiSubstitutor substitutorForMethod = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature, superSignature); - if (substitutorForMethod == null) return -1; for (int i = 0; i < checkedExceptions.size(); i++) { - PsiType exception = substitutorForDerivedClass.substitute(substitutorForMethod.substitute(checkedExceptions.get(i))); + final PsiClassType checkedEx = checkedExceptions.get(i); + final PsiType substituted = substitutorForMethod != null ? substitutorForMethod.substitute(checkedEx) : TypeConversionUtil.erasure(checkedEx); + PsiType exception = substitutorForDerivedClass.substitute(substituted); if (!isMethodThrows(superMethod, substitutorForMethod, exception, substitutorForDerivedClass)) { return i; } @@ -304,10 +305,10 @@ public class HighlightMethodUtil { return -1; } - private static boolean isMethodThrows(PsiMethod method, PsiSubstitutor substitutorForMethod, PsiType exception, PsiSubstitutor substitutorForDerivedClass) { + private static boolean isMethodThrows(PsiMethod method, @Nullable PsiSubstitutor substitutorForMethod, PsiType exception, PsiSubstitutor substitutorForDerivedClass) { PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes(); for (PsiClassType thrownException1 : thrownExceptions) { - PsiType thrownException = substitutorForMethod.substitute(thrownException1); + PsiType thrownException = substitutorForMethod != null ? substitutorForMethod.substitute(thrownException1) : TypeConversionUtil.erasure(thrownException1); thrownException = substitutorForDerivedClass.substitute(thrownException); if (TypeConversionUtil.isAssignable(thrownException, exception)) return true; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA87860.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA87860.java new file mode 100644 index 000000000000..540ec4e4195d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA87860.java @@ -0,0 +1,11 @@ +interface A { + void foo() throws T; + void bar() throws Exception; + void baz() throws Exception; +} + +interface B extends A { + void foo() throws T; + void bar() throws Throwable; + void baz() throws Throwable; +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 0333f9ed2769..10efbc903bbc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -315,6 +315,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA67843() { doTest5(false); } public void testAmbiguousTypeParamVsConcrete() { doTest5(false); } public void testRawAssignments() throws Exception { doTest5(false); } + public void testIDEA87860() throws Exception { doTest5(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));