[
https://issues.apache.org/jira/browse/GROOVY-9960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles resolved GROOVY-9960.
---------------------------------
Resolution: Fixed
Groovy compiler reports error for class B since it cannot create implicit
constructor without user intervention: "Implicit super constructor A() is
undefined for generated constructor. Must define an explicit constructor."
> STC fails to report missing constructor
> ---------------------------------------
>
> Key: GROOVY-9960
> URL: https://issues.apache.org/jira/browse/GROOVY-9960
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 3.0.7
> Reporter: Thodoris Sotiropoulos
> Priority: Major
>
> I have the following (incorrect) program
> {code:java}
> class A {
> String x;
> public A(String x) {
> this.x = x;
> }
> }
> class B extends A {}
> public class Main {
> public static void main(String[] args) {
> B x = new B();
> }
> }
> {code}
> h3. Actual Behaviour
> The program compiles and when I run it I get the following RuntimeException,
> because we are missingĀ a constructor for class `A` that takes no parameters.
> {code:java}
> Exception in thread "main" java.lang.NoSuchMethodError: A: method 'void
> <init>()' not found
> at B.<init>(test.groovy)
> at Main.main(test.groovy:13)
> {code}
> h3. Expected Behaviour
> The program should not compile and the compiler should report an error
> message, e.g., something similar to the one produced by javac.
> {code:java}
> Main.java:8: error: constructor A in class A cannot be applied to given types;
> class B extends A {}
> ^
> required: String
> found: no arguments
> reason: actual and formal argument lists differ in length
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)