[fpc-devel] Failure to recompile TAChart after FPC r40785 (committed by Jonas)
Jonas Maebe
jonas at freepascal.org
Mon Jan 7 20:36:06 CET 2019
On 07/01/19 20:12, Mattias Gaertner via fpc-devel wrote:
> On Mon, 7 Jan 2019 19:24:53 +0100
> Jonas Maebe <jonas at freepascal.org> wrote:
>
>> Object class methods do have a self parameter. If an object has a
>> vmt, the object class methods get this vmt pointer passed as self
>> parameter. Otherwise they get nil as self parameter. Kylix does not
>> support calling object class methods through tobjecttype.classmethod
>> either, which is indeed kind of strange.
>
> Thanks. I learned something new.
>
> But what is this Self?
>
> TBird = object
> class procedure DoIt; virtual;
> end;
>
> class procedure TBird.DoIt;
> var
> o: TBird;
> begin
> o:=Self;
> // Error: Incompatible types: got "Class Of TBird" expected "TBird"
> end;
>
> But "Class Of TBird" does not exist in FPC, does it?
No, it does not. The compiler currently unconditionally creates a
classrefdef for the self parameter, regardless of whether it's a class
or object type. This should probably changed into void pointer for
objects. Although even Kylix prints "Error: Incompatible types: "TBird"
and "Class Reference", so it seems we're also Delphi-compatible here :)
Jonas
More information about the fpc-devel
mailing list