Error XS0505 ..cannot override because .. is not a function

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Error XS0505 ..cannot override because .. is not a function

Post by ic2 »

Sorry, another one. It is not further documented. The method below originally yielded an error because it was of CLASS TextControl. As it is only used to set the Textcolor of 1 or 2 SLE's I changed it to class IC2SLE (my SingleLineEdit subclass) and moved it (in X#) to a prg with other methods of this class. So it looks now as follows:
PARTIAL CLASS IC2SLE INHERIT SingleLineEdit
....
METHOD TextColor(uValue)
SELF:TextColor:=uValue
RETURN NIL

Works as expected in VO, but in X# it gives this error:

Error XS0505 'IC2SLE.TextColor(params XSharp.__Usual[])': cannot override because 'VO.TextControl.TextColor' is not a function IC2 lib C:XporterOutputOkIC2 libControl.prg 459

What does this mean?

Dick
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Error XS0505 ..cannot override because .. is not a function

Post by robert »

Dick,
In DotNet you cannot have a method and a field or property with the same name.
Your code declares a method TextColor and the class already has a property TextColor.
If you enable the compiler option "all methods are virtual" then we add the Override modifier to all methods that you declare in your code. The backend (Roslyn) is getting confused because it finds a TextColor property and tries to override that, but you are overriding the property with a method.

Of course the question is: why did you add a method when there is already a property (ACCESS/ASSIGN in VO)?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Error XS0505 ..cannot override because .. is not a function

Post by ic2 »

Hello Robert,
Of course the question is: why did you add a method when there is already a property (ACCESS/ASSIGN in VO)?
I asked myself the same question: why did I write this 18 years ago. This is the code which uses that method:

SELF:oDCmSomeSLEField:TextColor(Color{nOpmFGR,nOpmFGG,nOpmFGB}) (where the 3 parameters are the foreground RGB colours)

If I rename the METHOD TextColor(uValue) the field is not colored anymore. At least, in VO (I have not yet converted the library where this TextColor call is applied). No idea why not to be honest.

I already set All instance methods are virtual to true but the error remained.

Dick
Post Reply