[
https://issues.apache.org/jira/browse/GROOVY-6174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King resolved GROOVY-6174.
-------------------------------
Resolution: Fixed
Assignee: Paul King
This seems to be fixed on recent versions of Groovy. Please reopen if you have
further problems.
> Groovy support of class inner enums is strange
> ----------------------------------------------
>
> Key: GROOVY-6174
> URL: https://issues.apache.org/jira/browse/GROOVY-6174
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 2.1.3
> Reporter: Pavel
> Assignee: Paul King
> Priority: Critical
>
> pack.MyClassWithEnumPack.groovy:
> {code}
> package pack
> class MyClassWithEnumPack {
> public static enum MyEnum{ ONE, TWO, THREE }
> def static howdy() {
> println 'Howdy'
> }
> }
> {code}
> enum-test.groovy:
> {code}
> import pack.MyClassWithEnumPack
> //
> http://testinfected.blogspot.ru/2008/01/dry-groovy-how-to-get-groovy-to-import.html
> new MyClassWithEnumPack().howdy()
> MyClassWithEnumPack.MyEnum t;
> println t;
> {code}
> Fails to run:
> {code}
> [pasha@hubbitus testpackage]$ groovy ./enum-test.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> /home/pasha/imus/imus-tools.GIT/testpackage/enum-test.groovy: 8: unable to
> resolve class MyClassWithEnumPack.MyEnum
> @ line 8, column 28.
> MyClassWithEnumPack.MyEnum t;
> ^
> 1 error
> {code}
> What very interesting, groovy really known about that enum, because code:
> {code}
> import pack.MyClassWithEnumPack
> println MyClassWithEnumPack.MyEnum.ONE;
> {code}
> Works!
> What even more interesting, it is compile time issue. If I comment out using
> of inner enum:
> {code}
> import pack.MyClassWithEnumPack
> //MyClassWithEnumPack.MyEnum t;
> //println t;
> {code}
> Then run compile:
> {code}
> $ groovyc ./enum-test.groovy
> {code}
> And then run initial variant:
> {code}
> $ groovy ./enum-test.groovy
> {code}
> it then works as expected and because there file
> pack/MyClassWithEnumPack$MyEnum.class present.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)