A bit of context. This is about the Problem with qualified enum names in switch cases like in the example:
enum MyEnum {
A,
B,
;
}
switch(methodReturnungMyEnum()){
case MyEnum.A:
// ...
break
case MyEnum.B:
// ...
break
}
which yields the compiler error
An enum switch case label must be the unqualified name of an enumeration constant
Yeah. The solution is simple: Remove MyEnum.
part. Thats not my question.
I was simply wondering why this is forbidden in the first place. I know that it is basically impossible to definitely answer why something was done in a certain way. Instead i want to ask for reasons that might have caused this decision. In what way are qualified and unqualified enum constants (or maybe symbols in general) different? And what could go wrong if the compiler would allow this anyway?
While there exists quite a few questions on how to fix the compiler error itself nobody seems to address above questions.