diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java index 8367c89f227f..c21e8d7f208a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java @@ -327,7 +327,8 @@ public class InvertIfConditionAction extends PsiElementBaseIntentionAction { } } } - if (thenBranch instanceof PsiContinueStatement) { + if (thenBranch instanceof PsiContinueStatement || + thenBranch instanceof PsiReturnStatement && ((PsiReturnStatement)thenBranch).getReturnValue() == null) { PsiStatement elseBranch = ifStatement.getElseBranch(); if (elseBranch != null) { elseBranch.delete(); diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterBrokenCodeWithTypeParameterDeclaredInside.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterBrokenCodeWithTypeParameterDeclaredInside.java index 96b0156d673a..f4e442ce1d81 100644 --- a/java/java-tests/testData/codeInsight/invertIfCondition/afterBrokenCodeWithTypeParameterDeclaredInside.java +++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterBrokenCodeWithTypeParameterDeclaredInside.java @@ -12,8 +12,5 @@ class A { }); } - else { - return; - } } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterFlow3.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterFlow3.java index c458d370f243..dfc54b13eeb8 100644 --- a/java/java-tests/testData/codeInsight/invertIfCondition/afterFlow3.java +++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterFlow3.java @@ -4,8 +4,5 @@ class A { if (c) { foo(); } - else { - return; - } } } \ No newline at end of file