Hi,

Consider the attached source code. I have a base interface (IA) and a
descendant interface (IB). Class TB is declared as

  TB = class(TInterfacedObject, IB) end;

Now I would expect that both

  Supports(TB, IA)
  Supports(TB, IB)

return true. After all, TB is forced to implement methods of both IA and
IB, as IB descends from IA. But to my surprise, Supports(TB, IA) returns
false.

Changing the declaration to

  TB = class(TInterfacedObject, IA, IB) end;

workarounds the problem (Supports(TB, IA) returns true), but seems
strange in my opinion.

I haven't found any explanation for this e.g. in docs
(http://freepascal.org/docs-html/rtl/sysutils/supports.html ,
http://freepascal.org/docs-html/ref/refch7.html ).

Is this the expected behavior? Documented anywhere? Or is this a bug,
and I should submit it?

Thanks,
Michalis
{$mode objfpc}

uses SysUtils;

type
  IA = interface
  ['{5E3D46A0-71B5-4561-B6B4-43A5BE5896EF}']
  end;

  IB = interface(IA)
  ['{19D68914-F2BA-4CFA-90A1-F561DB264678}']
  end;

  TA = class(TInterfacedObject, IA) end;
  TB = class(TInterfacedObject, IB) end;

begin
  Writeln(Supports(TA, IA)); // true
  Writeln(Supports(TA, IB)); // false
  Writeln(Supports(TB, IA)); // should be true, but is false ??
  Writeln(Supports(TB, IB)); // true
end.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to