Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3283

Can't "import static" more than one enum

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.7
    • 1.6-rc-2, 1.5.8, 1.7-beta-1
    • Compiler
    • None
    • Windows, XP, JRE 1.6.0

    Description

      Trying to use "import static Foo.*" for more than one enum throws on use even though the names don't collide. It's behaving like "with".

       
      enum Foo { A,B }
      enum Bar { X,Y }
      
      import static Foo.*
      import static Bar.*
      
      a = A
      x = X
      

      throws:

       
      java.lang.ExceptionInInitializerError
      	at Script146.class$(Script146)
      	at Script146.run(Script146:9)
      Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'X' with class 'Foo' to class 'Bar'
      	at Bar.<clinit>(Script146)
      	... 2 more
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            cityhall Chris Currivan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: