'E2250: There is no overloaded version of...' 关于错误键入的通用标识符
'E2250: There is no overloaded version of...' on miss-typed generic identifier
我的代码(简化为下面的代码片段)无法编译。 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 检查是否有具有兼容签名的函数。
PS:特别感谢@DavidHeffernan 的耐心等待。我愿意学习如何提出好的问题,尽管我相信一开始是通过提出一些不好的问题来练习的。 ;)
我的代码(简化为下面的代码片段)无法编译。 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 检查是否有具有兼容签名的函数。
PS:特别感谢@DavidHeffernan 的耐心等待。我愿意学习如何提出好的问题,尽管我相信一开始是通过提出一些不好的问题来练习的。 ;)