Hello,
in our project I get a false positive W534 (Class instance ''Foo'' passed to ''Bar'' but interface expected) warning.
I constructed a minimal example that reproduces the behaviour (I marked the line of question with a comment):
unit TFI.W534;
interface
uses
System.Classes;
type
IMyItem = interface(IInterface)
['{EAD54B97-1213-4076-B3A5-0A2D79F3962B}']
function GetName: string;
procedure SetName(const AName: string);
property Name: String read GetName write SetName;
end;
TMyItem = class(TObject)
strict private
FName: string;
public
constructor Create(const AItem: IMyItem);
property Name: string read FName write FName;
end;
TMyList = class(TList)
public
procedure Add(const AItem: IMyItem); reintroduce;
end;
implementation
uses
System.SysUtils;
var
MList: TMyList;
{ TMyList }
procedure TMyList.Add(const AItem: IMyItem);
var
LItem: TMyItem;
begin
LItem := TMyItem.Create(AItem);
inherited Add(LItem); // This line issues a false positive W534, although inherited TList.Add expects a pointer, not an interface. It seems FixInsight doesn't get the "inherited" or the "reintroduce" right.
end;
{ TMyItem }
constructor TMyItem.Create(const AItem: IMyItem);
begin
FName := AItem.Name;
end;
initialization
MList := TMyList.Create;
finalization
FreeAndNil(MList);
end.
Please let me known if you need further information on this. Thank you.
Kind regards,
Thorsten Schroff