Community
Participate
Working Groups
Build Identifier: Xtext 2.0.0.v201105230203 this works fine: def getEnumType(BaseTypeEnum enumType) { if (enumType == BaseTypeEnum::FLOAT) { // ... } } this does not work: def getEnumType(BaseTypeEnum enumType) { switch enumType { BaseTypeEnum::FLOAT : // (no viable alternatives at input '::') } } Reproducible: Always Steps to Reproduce: 1. see details 2. 3.
workaround: use if statements instead
You used a type guard instead of a case. The following should work: def getEnumType(BaseTypeEnum enumType) { switch enumType { case BaseTypeEnum::FLOAT : // note the 'case' keyword } } Please refer to the docs for details on the syntax. Please reopen if the switch does not work for you.
what about this? def getEnumType(BaseTypeEnum enumType) { switch enumType { case BaseTypeEnum::FLOAT || BaseTypeEnum::DOUBLE : // <= not supported case BaseTypeEnum::FLOAT || case BaseTypeEnum::DOUBLE : // <= also not supported } } woraround: def getEnumType(BaseTypeEnum enumType) { switch { case (enumType == BaseTypeEnum::UNSPECIFIED || enumType == BaseTypeEnum::ANY): // this works but is not so nice :-) } } thanks serano
works as expected.
Closing all bugs that were set to RESOLVED before Neon.0