我的代码(简化为下面的代码片段)无法编译。 Delphi XE4 的编译器返回此消息:
E2250: There is no overloaded version of 'Sort' that can be called with these arguments
。
program Project1;
{$APPTYPE CONSOLE}
uses
System.Generics.Collections;
type
TSomeGenericType<TKey, TData> = class (TObject);
function GetSortedArray: TArray<TSomeGenericType<Integer, TObject>>;
begin
// ... omitted code to initialize Result
TArray.Sort<TSomeGenericType<Integer, TObject>(Result);
// !!! E2250: There is no overloaded version of 'Sort' that can be called with these
// arguments
end;
begin
end.
正如对此问题的评论中已经指出的,错误的原因是一个微小的拼写错误。而不是
TArray.Sort<TSomeGenericType<Integer, TObject>(Result);
应该是
TArray.Sort<TSomeGenericType<Integer, TObject>>(Result);
我认为,解析器应该注意到 before 检查是否存在具有兼容签名的函数。