question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add class qualified is broken for enums

See original GitHub issue

Bug Description When the flag is activated, the plugin adds class qualifier to static member access outside classes which is nice. However, when you are inside a switch-case for an enum. It is adding the enum name as qualifier which is not allowed

To Reproduce

  1. Create an enum, say:

    enum Day {
       MON, WED, FRI
    }
    
  2. Create a Main class, say:

    public class Main {
         public static void main(String[] args) {
                Day day = Day.MON;
                switch (day) {
                    case MON:
                         System.out.println("oh no");
                        break;
                    case WED:
                         System.out.println("oh ok");
                        break;
                     case FRI:
                         System.out.println("oh nice");
                        break;
                      default: break;
                }
         }
    }
    

Expected behavior The above should be kept as is!

Actual behavior The plugin does: case Day.MON, case Day.WED, case Day.FRI which weirdly is not allowed in Java

On compilation, this error is thrown:

an enum switch case label must be the unqualified name of an enumeration constant

Versions IntelliJ IDEA 2019.1 EAP (Ultimate Edition) Build #IU-191.5849.21, built on February 27, 2019 IntelliJ IDEA EAP User Expiration date: March 29, 2019 JRE: 1.8.0_202-release-1483-b31 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 7 6.1

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dubreuiacommented, Jan 12, 2020

Ok, reopening. PRs welcomed.

0reactions
bjrkecommented, Jan 13, 2020

@dubreuia: I can confirm the not fully fixed issue of @RSLak1 in 2019.3.1 with version 1.9.0 and 2019.2.4 with unknown version both linux and community edition

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Can I extend a class and override enclosed enum type?
The problem in your situation is called hiding rather than overriding enums, and two above enums aren't related to each other. If you...
Read more >
Persisting Enums in JPA - Baeldung
A quick and practical guide to persisting enums in JPA. ... Next, let's add it to the Article class and annotate it with ......
Read more >
Java Enum Tutorial: 10 Examples of Enum in Java
2) Enum in Java are reference types like class or interface and you can define constructor, methods, and variables inside java Enum which...
Read more >
JDK-6191812 Ability to use qualified enums in case statements
JUSTIFICATION : Allow the use of qualified enum constants in switch/case statements to be ... public class EnumClass { public enum Action {...
Read more >
Examining Enums - The Reflection API
Given a fully qualified name, the EnumConstants example shows how to retrieve an ordered list of constants in an enum using Class.getEnumConstants() ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found