[fpc-devel] Sven commit (r34087) breaks casting an object to an interface

Dimitrios Chr. Ioannidis d.ioannidis at nephelae.eu
Fri Jul 15 13:01:45 CEST 2016


On 15/7/2016 1:31 μμ, Juha Manninen wrote:
> On Fri, Jul 15, 2016 at 12:51 PM, Maciej Izak <hnb.code at gmail.com> wrote:
>> constructor TDesignFormData.Create(AForm: TCustomForm);
>> begin
>>    FForm := AForm as IDesignedForm; // won't work anymore. FForm is an
>> interface
> I have not studied the context of this code but to me it looks suspicious.
> If such a typecast is needed then something is wrong in the code's design.
> An obvious idea is to change the AForm's type to IDesignedForm.
> My intuition says that Sven's commit only revealed some fishy code in
> sparta dockedformeditor.

AFAIU, unless the AForm  ( a TCustomForm descendant which explicitly 
list IDesignedForm  ) doesn't has the IDesignedForm in it's list of 
supported interfaces, then it's a bug in the compiler, because, AFAIU, 
the compiler is relying on this in order to implement the as cast, no ?

regards,
-- 
Dimitrios Chr. Ioannidis



More information about the fpc-devel mailing list