delphigenericsdelphi-xe4

'E2250: There is no overloaded version of...' on miss-typed generic identifier


My code (reduced to the snippet below) does not compile. Delphi XE4's compiler returned this message: 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.

Solution

  • As already stated in the comments to this question the error's cause is a tiny typo. Instead of

    TArray.Sort<TSomeGenericType<Integer, TObject>(Result); 
    

    it should be

    TArray.Sort<TSomeGenericType<Integer, TObject>>(Result); 
    

    I'd think, the parser should note that before checking if there is an function with a compatible signature.