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

Unable to resolve nested enum of parent class when compiling against binary parent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.3, 2.3.8
    • None
    • None
    • Tested on JDK 1.7.0_51 32 bit Windows

    Description

      Base.groovy
      class Base {
        public static enum Color { Red, Green }
        
        public Color getColor() { Color.Red }
      }
      
      Child.groovy
      class Child extends Base {
        @Override
        public Color getColor() { Color.Green }
      }
      

      Steps to reproduce:

      1. groovyc Base.groovy
      2. rm Base.groovy
      3. groovyc Child.groovy

      Note that `groovyc *.groovy` works, as well as putting the code into the groovyconsole. It seems that this bug is triggered only when Base.groovy source is not in sourcepath.

      Workaround is to put `import Base.Color` in Child.groovy. However, IDEs like IntelliJ IDEA show this as an unnecessary import and remove the import when optimizing imports (which can happen on every save depending on IDE settings). Another workaround is to put absolute qualifier on Color enum, but IDEA also provides warning for this.

      Attachments

        1. Child.groovy
          0.1 kB
        2. Base.groovy
          0.1 kB

        Activity

          People

            daniel_sun Daniel Sun
            gillius Jason Winnebeck
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: