diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java index e413070058ee..549fff6f4c3f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java @@ -375,7 +375,9 @@ public class ConvertSwitchToIfIntention implements IntentionActionWithFixAllOpti if (aClass == null) { return commentTracker.text(value); } - return aClass.getQualifiedName() + '.' + commentTracker.text(referenceExpression); + String qualifiedName = aClass.getQualifiedName(); + String className = qualifiedName != null ? qualifiedName : aClass.getName(); + return className + '.' + commentTracker.text(referenceExpression); } private static void dumpBody(SwitchStatementBranch branch, @NonNls StringBuilder out, CommentTracker commentTracker) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convertSwitchToIf/afterLocalEnum.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convertSwitchToIf/afterLocalEnum.java new file mode 100644 index 000000000000..7aa60a6a2fde --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convertSwitchToIf/afterLocalEnum.java @@ -0,0 +1,11 @@ +// "Replace 'switch' with 'if'" "true" +class Test { + void test() { + enum P { + s; + } + P p = null; + if (p == P.s) { + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convertSwitchToIf/beforeLocalEnum.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convertSwitchToIf/beforeLocalEnum.java new file mode 100644 index 000000000000..96679852725e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convertSwitchToIf/beforeLocalEnum.java @@ -0,0 +1,13 @@ +// "Replace 'switch' with 'if'" "true" +class Test { + void test() { + enum P { + s; + } + P p = null; + switch (p) { + case s -> {} + default -> {} + } + } +} \ No newline at end of file