Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.5
-
None
-
None
-
Mac OS X 10.7.5, IntelliJ IDEA 11.1.3
Description
For illustration see the code below:
import javax.xml.stream.XMLStreamConstants enum MyEnum { INSTANCE { String getName(int i) { switch (i) { case javax.xml.stream.XMLStreamConstants.START_ELEMENT: return "START_ELEMENT" case XMLStreamConstants.END_ELEMENT: return "END_ELEMENT" } } } } println MyEnum.INSTANCE.getName(XMLStreamConstants.START_ELEMENT) println MyEnum.INSTANCE.getName(XMLStreamConstants.END_ELEMENT)
The first invokation of getName succeeds because the constant is referenced with its fully qualified name in the first case statement. The second however fails in spite of the fact that the referenced class is imported.
Exact output of the script is:
START_ELEMENT Caught: groovy.lang.MissingPropertyException: No such property: XMLStreamConstants for class: MyEnum$1 groovy.lang.MissingPropertyException: No such property: XMLStreamConstants for class: MyEnum$1 at MyEnum$1.getName(EnumMemberMethodWithSwitchTest.groovy:9) at MyEnum$1$getName.call(Unknown Source) at EnumMemberMethodWithSwitchTest.run(EnumMemberMethodWithSwitchTest.groovy:18) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)