Keith R. Bennett | 1 May 2008 15:22

Re: [groovy-user] Call to super(arg) Fails


Thank you, Andres.  I gues that was my silly syntactical mistake. ;)

I've only looked at this issue for a short time, but I can't see any pattern
as to when parentheses are needed and when they're not.  Does anyone know
what the pattern is?  And is it by design, or by accident?

Thanks,
Keith

Andres Almiray wrote:
> 
> Putting parenthesis on the call to super make your code work, perhaps this
> is one of those rare occasions where parenthesis can't be omitted ?
> 
> 
> Keith R. Bennett wrote:
>> 
>> Hello.  I'm trying to create an instance of a class that subclasses
>> another class.  However, when I include an explicit call to a superclass
>> constructor that takes an argument, it fails.  I'm coming back to Groovy
>> after many months away, so I may be making a silly syntactical mistake. 
>> I'm pasting the code, and the output below.
>> 
>> Thanks for any help.
>> 
>> - Keith
>> 
>> 
>> Code:
>> =====
>> 
>> class Base {
>>     Base() {
>>         System.out.println 'created a Base';
>>     }
>> 
>> 
>>     Base(s) {
>>         System.out.println s  
>>     }
>> }
>> 
>> 
>> class Derived extends Base {
>>     Derived() {
>>         super 'foo'
>>         System.out.println 'created a Derived';
>>     }
>> }
>> 
>> 
>> new Base('calling new Base()')
>> new Derived()
>> 
>> 
>> Output:
>> =======
>> 
>> calling new Base()
>> created a Base
>> Caught: groovy.lang.MissingMethodException: No signature of method:
>> Derived.super() is applicable for argument types: (java.lang.String)
>> values: {"foo"}
>> 	at Derived.<init>(Test.groovy:15)
>> 	at Test.run(Test.groovy:22)
>> 	at Test.main(Test.groovy)
>> 
>> Process finished with exit code 1
>> 
>> 
> 
> 

--

-- 
View this message in context: http://www.nabble.com/Call-to-super%28arg%29-Fails-tp16992759p16993245.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane