Using Delphi XE-2 (all updates applied).
I would expect the following code to generate compilation errors on the DoSomething and DoInteger calls, but it doesn't.
program OpenArrayQuestion;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
IComposite = interface(IInterface)
['{1AC3CF6A-1316-4838-B67B-9FB075585C1E}']
end;
IComposite<T: IComposite> = interface(IComposite)
['{7F866990-9973-4F8E-9C1F-EF93EF86E8F2}']
end;
function DoSomething(const aData: array of IComposite): Boolean;
begin
Result := True;
end;
function DoInteger(const aData: array of Integer): boolean;
begin
Result := True;
end;
var
FData: IComposite;
FInteger: Integer;
begin
DoSomething(FData);
DoInteger(FInteger);
end.
Can somebody explain why I can pass FData/FInteger - both just single variables, to an open array parameter of their respective types without putting it between []
's and without the compiler barfing it right back at me?
I thought it might have to do with an array of interfaces, or even the generics involved, but the compiler accepts an integer passed to an open array of integer as well.