IDEA-115573 (Bogus "Throwable result of a method ignored" in ternary expression.)

This commit is contained in:
Bas Leijdekkers
2016-07-17 23:55:48 +02:00
parent df78a3f309
commit 021c8574c9
2 changed files with 7 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2015 Bas Leijdekkers
* Copyright 2008-2016 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,8 @@ public class ThrowableResultOfMethodCallIgnoredInspection extends BaseInspection
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
PsiElement parent = expression.getParent();
while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiTypeCastExpression) {
while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiTypeCastExpression ||
parent instanceof PsiConditionalExpression) {
parent = parent.getParent();
}
if (!TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_THROWABLE)) {
@@ -19,6 +19,10 @@ public class ThrowableResultOfMethodCallIgnored {
throw (RuntimeException) b();
}
void n(int i) throws Exception {
throw i == 0 ? null : b();
}
public Exception b() {
return new RuntimeException();
}