On Mon, 2 Feb 2026, Martin Frb via fpc-devel wrote:

If I have the below code, I can pass an object that has I1 (TFoo if uncommented) to the test function

I can also pass an inherited interface. "x1: i2"

But I can not pass a call that only has the inherited interface?
 Error: Class "TFoo" does not implement interface "I1"

Is that intended?

Yes


Since TFoo implement I2, it does also implement I1.

No. The inheritance is just a typing convenience.

When you do an "as interface", then the compiler looks for the UUID of the
interface in a table.

If you define
  TFoo = class(TObject, I2)
only the UUID of I2 is inserted in the table.

but if you define
  TFoo = class(TObject, I1, I2)
then the table will contain both UUIDS and the "as I1" will work.

This is delphi compatible.

Michael.
_______________________________________________
fpc-devel maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to