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

@InheritConstructors does not work on inner classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.7.5, 1.7.6, 1.8.6
    • 2.0-beta-3
    • class generator
    • Tested on Fedora and Windows 7. Both show same issue.

    Description

      When you use the @InheritConstructors to pull all the constructors of a super class into a subclass this fails to work when it is used on an Inner Class. Below is an example of code that fails with error:

      groovy.lang.GroovyRuntimeException: Could not find matching constructor for: D$F(D, java.lang.Integer)
      

      when you would expect it to run.

      import groovy.transform.InheritConstructors
      
      class A {
          def arg
          A(int arg) {this.arg=arg}
      }
      
      @InheritConstructors //add it here just in case that worked!
      class D {
          class E extends A {
              E(int arg) {super(arg)}
          }
          @InheritConstructors //this should make class F identical to class E
          class F extends A{}
         
          public test() {
              def test1=new E(1) //Works FINE.
              println test1.arg  // prints 1 as expected  
              def test2=new F(1) //throws GroovyRuntimeException here due to missing constructor.
              println test2.arg
          }
      }
      
      def test3=new D()
      test3.test()
      

      Attachments

        1. innerClassError.groovy
          0.6 kB
          Robin Owens

        Activity

          People

            paulk Paul King
            owensr Robin Owens
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: