diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java index b5660e85ca07..b37f8f94a109 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java @@ -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)) { diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_result_of_method_call_ignored/ThrowableResultOfMethodCallIgnored.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_result_of_method_call_ignored/ThrowableResultOfMethodCallIgnored.java index 49adcc64ebfe..dc9c1aa12909 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_result_of_method_call_ignored/ThrowableResultOfMethodCallIgnored.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_result_of_method_call_ignored/ThrowableResultOfMethodCallIgnored.java @@ -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(); }