Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.7.5, 1.7.6, 1.8.6
-
Fix Version/s: 2.0-beta-3
-
Component/s: class generator
-
Labels:
-
Environment:Tested on Fedora and Windows 7. Both show same issue.
-
Number of attachments :
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()
Activity
Robin Owens
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | innerClassError.groovy [ 53252 ] |
Paul King
made changes -
| 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$E(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 incase 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() |
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:
{noformat} groovy.lang.GroovyRuntimeException: Could not find matching constructor for: D$E(D, java.lang.Integer) {noformat} when you would expect it to run. {code} 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() {code} |
Paul King
made changes -
| Affects Version/s | 1.8.6 [ 18245 ] |
Paul King
made changes -
| 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:
{noformat} groovy.lang.GroovyRuntimeException: Could not find matching constructor for: D$E(D, java.lang.Integer) {noformat} when you would expect it to run. {code} 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() {code} |
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:
{noformat} groovy.lang.GroovyRuntimeException: Could not find matching constructor for: D$F(D, java.lang.Integer) {noformat} when you would expect it to run. {code} 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() {code} |
Paul King
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | blackdrag blackdrag [ blackdrag ] | Paul King [ paulk ] |
| Fix Version/s | 2.0-beta-3 [ 18244 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Labels | breaking |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Sorry - typo in description - exception should be:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: D$F(D, java.lang.Integer)
(The class is D$F no D$E)