History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2836
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Guillaume Laforge
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Misleading MissingMethodException thrown when this() is called inside a constructor

Created: 16/May/08 04:54 PM   Updated: 16/May/08 04:54 PM
Component/s: command line processing
Affects Version/s: 1.6-beta-1, 1.5.6
Fix Version/s: 1.5.7, 1.6-beta-2

Time Tracking:
Not Specified


 Description  « Hide
class Foo {
    Foo(String s) {}

    Foo(Date d) {
        println "call to this() must be the first statement of a ctor"
        this(d.toString())
    }
}

new Foo(new Date())

In the snippet above, I'm calling this() after a println call.
But in Java, it is mandatory that calls to this() or super() inside a constructor are the first statements of the block.
Here I get the following stacktrace:

groovy.lang.MissingMethodException: No signature of method: Foo.call() is applicable for argument types: (java.lang.String) values: {Fri May 16 23:48:20 CEST 2008}
	at Foo.invokeMethod(Script35)
	at Foo.<init>(Script35:6)
	at Script35.run(Script35:10)

The compiler should check that calls to this() or super() are done as the first statement, and not afterwards.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.