IDEA-111613 Bad code is green: IDEA doesn't show 'Unhandled exception' error when a method with parametrized 'throws' section is used with wildcard type argument

This commit is contained in:
anna
2013-08-06 13:49:10 +02:00
parent 1bd39a6322
commit 6d3989e21d
3 changed files with 15 additions and 1 deletions
@@ -541,7 +541,7 @@ public class ExceptionUtil {
List<PsiClassType> result = ContainerUtil.newArrayList();
for (PsiClassType referencedType : referencedTypes) {
final PsiType type = substitutor.substitute(referencedType);
final PsiType type = GenericsUtil.eliminateWildcards(substitutor.substitute(referencedType), false);
if (!(type instanceof PsiClassType)) continue;
PsiClassType classType = (PsiClassType)type;
PsiClass exceptionClass = ((PsiClassType)type).resolve();
@@ -0,0 +1,13 @@
interface I<T extends Exception> {
void m() throws T;
}
class C {
void x(I<?> i) {
<error descr="Unhandled exception: java.lang.Exception">i.m();</error>
}
void y(I<? extends Exception> i) {
<error descr="Unhandled exception: java.lang.Exception">i.m();</error>
}
}
@@ -58,4 +58,5 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
public void testClassObjectAccessibility() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(false, false); }
public void testRedundantCastInConditionalExpression() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
public void testJava5CastConventions() { setLanguageLevel(LanguageLevel.JDK_1_5); doTest(true, false); }
public void testUnhandledExceptions() { doTest(true, false); }
}