[fpc-devel] Assigning class methods, accessed via a class reference type, to procvars
Sven Barth
pascaldragon at googlemail.com
Thu May 26 21:54:44 CEST 2022
Am 22.12.2021 um 19:16 schrieb Blaise--- via fpc-devel:
> 1) The attached metaclass_meth_to_procvar-1.patch fixes the internal
> error reported for:
> [ICE] Assigning class methods, accessed via a class reference type, to
> incompatible procvars
> -------8<-------
> type C = class
> class procedure NonStatic;
> class procedure Static; static;
> end;
> class procedure C.NonStatic; begin end;
> class procedure C.Static; begin end;
>
> type CC = class of C;
>
> var IncompatWNonStatic: procedure;
> var IncompatWStatic: procedure of object;
> begin
> IncompatWNonStatic := CC.NonStatic; // ICE 200301042
> IncompatWStatic := CC.Static // ICE 200301042
> end.
> -------8<-------
>
>
> 2) The attached metaclass_meth_to_procvar-2.patch fixes the invalid
> codegen produced for:
> [BadCG] Assigning class non-static methods, accessed via a class
> reference type, to method pointers
> -------8<-------
> type C = class
> class procedure Foo;
> end;
> class procedure C.Foo; begin end;
>
> type CC = class of C;
>
> var Z: procedure of object;
> begin
> Z := CC.Foo;
> writeln( TMethod(Z).Code = @C.Foo ); // "FALSE"
> writeln( TMethod(Z).Data = Pointer(C) ); // "FALSE"
> end.
> -------8<-------
Both accepted.
Regards,
Sven
More information about the fpc-devel
mailing list